private void Channel_PushNotificationReceived(PushNotificationChannel sender, PushNotificationReceivedEventArgs args) { Debug.WriteLine("Push Notification Received " + args.NotificationType); JObject jobject = null; switch (args.NotificationType) { case PushNotificationType.Badge: jobject = JObject.FromObject(args.BadgeNotification, _serializer); break; case PushNotificationType.Raw: jobject = JObject.FromObject(args.RawNotification, _serializer); break; case PushNotificationType.Tile: jobject = JObject.FromObject(args.TileNotification, _serializer); break; case PushNotificationType.TileFlyout: jobject = JObject.FromObject(args.TileNotification, _serializer); break; case PushNotificationType.Toast: jobject = JObject.FromObject(args.ToastNotification, _serializer); break; } Debug.WriteLine("Sending JObject to PushNotificationListener " + args.NotificationType); _pushNotificationListener.OnMessage(jobject, Device.UWP); }
public void OnMessageReceived(NSDictionary userInfo) { var json = DictionaryToJson(userInfo); var values = JObject.Parse(json); var keyAps = new NSString("aps"); if (userInfo.ContainsKey(keyAps) && userInfo.ValueForKey(keyAps) is NSDictionary aps) { foreach (var apsKey in aps) { if (!values.TryGetValue(apsKey.Key.ToString(), out JToken temp)) { values.Add(apsKey.Key.ToString(), apsKey.Value.ToString()); } } } _pushNotificationListener.OnMessage(values, Device.iOS); }