/// <summary> /// Returns the notification list. /// </summary> /// <exception cref="UnauthorizedAccessException"> Thrown in case of a permission is denied.</exception> /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception> /// <privilege>http://tizen.org/privilege/notification</privilege> /// <since_tizen> 4 </since_tizen> public static IList <NotificationEventArgs> GetList() { Interop.NotificationEventListener.ErrorCode err; IntPtr notificationList = IntPtr.Zero; IntPtr currentList = IntPtr.Zero; IList <NotificationEventArgs> list = new List <NotificationEventArgs>(); err = Interop.NotificationEventListener.GetList(NotificationType.None, -1, out notificationList); if (err != Interop.NotificationEventListener.ErrorCode.None) { throw NotificationEventListenerErrorFactory.GetException(err, "unable to get notification list"); } if (notificationList != IntPtr.Zero) { currentList = notificationList; while (currentList != IntPtr.Zero) { IntPtr notification; NotificationEventArgs eventargs = new NotificationEventArgs(); notification = Interop.NotificationEventListener.GetData(currentList); eventargs = NotificationEventArgsBinder.BindObject(notification, false); list.Add(eventargs); currentList = Interop.NotificationEventListener.GetNext(currentList); } Interop.NotificationEventListener.NotificationListFree(notificationList); } return(list); }
public static NotificationEventArgs GetNotificationEventArgs(int uniqueNumber) { if (uniqueNumber <= 0) { throw NotificationEventListenerErrorFactory.GetException(Interop.NotificationEventListener.ErrorCode.InvalidParameter, "Invalid parameter"); } IntPtr notificationPtr = Interop.NotificationEventListener.LoadNotification(null, uniqueNumber); if (notificationPtr == IntPtr.Zero) { int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult(); if (err.Equals((int)Interop.NotificationEventListener.ErrorCode.DbError)) { throw NotificationEventListenerErrorFactory.GetException(Interop.NotificationEventListener.ErrorCode.InvalidParameter, "Not exist"); } else { throw NotificationEventListenerErrorFactory.GetException((Interop.NotificationEventListener.ErrorCode)err, "failed to get NotificationEventArgs"); } } NotificationEventArgs eventArgs = new NotificationEventArgs(); eventArgs = NotificationEventArgsBinder.BindObject(notificationPtr, false); return(eventArgs); }
public static void SendEvent(int uniqueNumber, UserEventType type) { Interop.NotificationEventListener.ErrorCode err; err = Interop.NotificationEventListener.SendEvent(uniqueNumber, (int)type); if (err != Interop.NotificationEventListener.ErrorCode.None) { throw NotificationEventListenerErrorFactory.GetException(err, "failed to send event"); } }
/// <summary> /// Deletes a notification with appId and uniqueNumber. /// </summary> /// <param name="appId">The name of the application you want to delete.</param> /// <param name="uniqueNumber">The unique number of the notification.</param> /// <exception cref="ArgumentException">Thrown in case of an invalid parameter.</exception> /// <exception cref="UnauthorizedAccessException"> Thrown in case of a permission is denied.</exception> /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception> /// <privilege>http://tizen.org/privilege/notification</privilege> /// <since_tizen> 4 </since_tizen> public static void Delete(string appId, int uniqueNumber) { Interop.NotificationEventListener.ErrorCode err; if (string.IsNullOrEmpty(appId) || uniqueNumber < 0) { throw NotificationEventListenerErrorFactory.GetException(Interop.NotificationEventListener.ErrorCode.InvalidParameter, "invalid parameter"); } err = Interop.NotificationEventListener.Delete(appId, 0, uniqueNumber); if (err != Interop.NotificationEventListener.ErrorCode.None) { throw NotificationEventListenerErrorFactory.GetException(err, "unable to delete"); } }
/// <summary> /// Deletes all notifications. /// </summary> /// <exception cref="UnauthorizedAccessException"> Thrown in case of a permission is denied.</exception> /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception> /// <privilege>http://tizen.org/privilege/notification</privilege> /// <since_tizen> 4 </since_tizen> public static void DeleteAll() { Interop.NotificationEventListener.ErrorCode err; err = Interop.NotificationEventListener.DeleteAll((int)NotificationType.Notification); if (err != Interop.NotificationEventListener.ErrorCode.None) { throw NotificationEventListenerErrorFactory.GetException(err, "delete all notifications failed of Noti type"); } err = Interop.NotificationEventListener.DeleteAll((int)NotificationType.Ongoing); if (err != Interop.NotificationEventListener.ErrorCode.None) { throw NotificationEventListenerErrorFactory.GetException(err, "delete all notifications failed of Ongoing type"); } }
/// <summary> /// Gets the ExtraDataArgs. /// </summary> /// <param name="key">The key that specifies which extra data.</param> /// <returns>Returns the bundle for key.</returns> /// <since_tizen> 4 </since_tizen> public Bundle GetExtraData(string key) { Bundle bundle; if (string.IsNullOrEmpty(key)) { throw NotificationEventListenerErrorFactory.GetException(Interop.NotificationEventListener.ErrorCode.InvalidParameter, "invalid parameter entered"); } if (ExtraData.TryGetValue(key, out bundle) == false) { throw NotificationEventListenerErrorFactory.GetException(Interop.NotificationEventListener.ErrorCode.InvalidParameter, "invalid parameter entered : " + key); } return(bundle); }
/// <summary> /// Gets the styleArgs of active, lock, indicator, and bigpicture. /// </summary> /// <typeparam name="T">Type of notification style to be queried.</typeparam> /// <returns>The NotificationEventListener.StyleArgs object associated with the given style.</returns> /// <exception cref="ArgumentException">Thrown when an argument is invalid.</exception> /// <since_tizen> 4 </since_tizen> public T GetStyle <T>() where T : StyleArgs, new() { T type = new T(); StyleArgs style = null; Style.TryGetValue(type.Key, out style); if (style == null) { Log.Error(LogTag, "Invalid Style"); throw NotificationEventListenerErrorFactory.GetException(Interop.NotificationEventListener.ErrorCode.InvalidParameter, "invalid parameter entered"); } else { return(style as T); } }
public static int GetAllCount() { int count; Interop.NotificationEventListener.ErrorCode error; error = Interop.NotificationEventListener.GetAllCount(NotificationType.None, out count); if (error != Interop.NotificationEventListener.ErrorCode.None) { if (error == Interop.NotificationEventListener.ErrorCode.PermissionDenied) { throw NotificationEventListenerErrorFactory.GetException(Interop.NotificationEventListener.ErrorCode.PermissionDenied, "failed to get all count"); } else { throw NotificationEventListenerErrorFactory.GetException(Interop.NotificationEventListener.ErrorCode.InvalidOperation, "failed to get all count"); } } return(count); }