protected virtual void Update() { if (!tokenSent) { byte[] token = NotificationServices.deviceToken; if (token != null) { hexToken = "%" + System.BitConverter.ToString(token).Replace('-', '%'); DevicePushIdReceived(hexToken); tokenSent = true; } } if (NotificationServices.localNotificationCount > 0) { LocalNotificationReceived(NotificationServices.localNotifications [0].alertBody); NotificationServices.CancelLocalNotification(NotificationServices.localNotifications [0]); NotificationServices.ClearLocalNotifications(); } if (NotificationServices.remoteNotificationCount > 0) { LocalNotificationReceived(NotificationServices.remoteNotifications [0].alertBody); NotificationServices.ClearRemoteNotifications(); } }
/// <summary> /// Checks the Notifications for one that matches the ID and cancels it if it exists. /// </summary> /// <param name="requestCode">Notification ID.</param> private void InternalCancelNotification(int requestCode) { int index = 0; while (NotificationServices.GetLocalNotification(index) != null) { index++; LocalNotification notification = NotificationServices.GetLocalNotification(index); if (notification.userInfo.Contains(NotificationID) && (int)notification.userInfo[NotificationID] == requestCode) { NotificationServices.CancelLocalNotification(notification); break; } } }
public override void CancelLocalNotification(string _notificationID) { foreach (LocalNotification _scheduledNotification in NotificationServices.scheduledLocalNotifications) { IDictionary _scheduledNotificationUserInfo = _scheduledNotification.userInfo; if (_scheduledNotificationUserInfo != null) { string _scheduledNotificationID = _scheduledNotificationUserInfo.GetIfAvailable <string>(CrossPlatformNotification.kNotificationID); // Cancel notification if (!string.IsNullOrEmpty(_scheduledNotificationID) && _scheduledNotificationID.Equals(_notificationID)) { NotificationServices.CancelLocalNotification(_scheduledNotification); break; } } } }
public virtual void CancelLocalNotification(string id = "") { LocalNotification[] notifis = NotificationServices.scheduledLocalNotifications; if (notifis.Length > 0) { if (id == "") { id = scheduleLocalNotification; } for (int i = 0; i < notifis.Length; i++) { if (notifis [i].userInfo ["id"].ToString() == id) { NotificationServices.CancelLocalNotification(notifis [i]); } } } }