/// <summary> /// Registers a callback for push notifications. /// </summary> /// <param name="action"></param> private void RegisteriOSPushNotificationListener(Action <IDictionary <string, object> > action) { Dispatcher.Instance.Post(() => { // Check in every frame RegisteriOSPushNotificationListener(action); int remoteNotificationCount = NotificationServices.remoteNotificationCount; if (remoteNotificationCount == 0) { return; } var remoteNotifications = NotificationServices.remoteNotifications; foreach (var val in remoteNotifications) { var userInfo = val.userInfo; var payload = new Dictionary <string, object>(); foreach (var key in userInfo.Keys) { payload[key.ToString()] = userInfo[key]; } // Finally, invoke the action for the remote notification payload. action(payload); } NotificationServices.ClearRemoteNotifications(); }); }
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(); } }
public override void ClearNotifications() { // Removing badge count NPBinding.Utility.SetApplicationIconBadgeNumber(0); // Clears notification NotificationServices.ClearLocalNotifications(); NotificationServices.ClearRemoteNotifications(); }