public static Notification NotificationToXam(OneSignaliOS.OSNotification notification) { Dictionary <string, object> additionalDataXam = new Dictionary <string, object>(); if (notification.AdditionalData != null) { additionalDataXam = NSDictToPureDict(notification.AdditionalData); } List <ActionButton> actionButtonsXam = new List <ActionButton>(); if (notification.ActionButtons != null) { foreach (NSObject actionButton in notification.ActionButtons) { Dictionary <string, string> actionButtonXam = NSObjectToPureDict(actionButton); if (actionButtonXam != null) { actionButtonsXam.Add(new ActionButton( actionButtonXam.GetValueOrDefault("id"), actionButtonXam.GetValueOrDefault("text"), actionButtonXam.GetValueOrDefault("icon") )); } } } return(new Notification { notificationId = notification.NotificationId, templateName = notification.TemplateName, templateId = notification.TemplateId, title = notification.Title, body = notification.Body, additionalData = additionalDataXam, launchUrl = notification.LaunchURL, sound = notification.Sound, relevanceScore = notification.RelevanceScore != null ? (float)notification.RelevanceScore : 0, rawPayload = notification.RawPayload.ToString(), badge = notification.Badge.ToString(), badgeIncrement = notification.BadgeIncrement.ToString(), actionButtons = actionButtonsXam, category = notification.Category, threadId = notification.ThreadId, subtitle = notification.Subtitle, mutableContent = notification.MutableContent, contentAvailable = notification.ContentAvailable, interruptionLevel = notification.InterruptionLevel }); }
private OSNotification OSNotificationToNative(iOS.OSNotification notif) { var notification = new OSNotification(); notification.displayType = (OSNotification.DisplayType)notif.DisplayType; notification.shown = notif.Shown; notification.silentNotification = notif.SilentNotification; notification.payload = new OSNotificationPayload(); notification.payload.actionButtons = new List <Dictionary <string, object> >(); if (notif.Payload.ActionButtons != null) { for (int i = 0; i < (int)notif.Payload.ActionButtons.Count; ++i) { Foundation.NSDictionary element = notif.Payload.ActionButtons.GetItem <Foundation.NSDictionary>((uint)i); notification.payload.actionButtons.Add(NSDictToPureDict(element)); } } notification.payload.additionalData = new Dictionary <string, object>(); if (notif.Payload.AdditionalData != null) { foreach (KeyValuePair <Foundation.NSObject, Foundation.NSObject> element in notif.Payload.AdditionalData) { notification.payload.additionalData.Add((Foundation.NSString)element.Key, element.Value); } } notification.payload.badge = (int)notif.Payload.Badge; notification.payload.body = notif.Payload.Body; notification.payload.contentAvailable = notif.Payload.ContentAvailable; notification.payload.launchURL = notif.Payload.LaunchURL; notification.payload.notificationID = notif.Payload.NotificationID; notification.payload.sound = notif.Payload.Sound; notification.payload.subtitle = notif.Payload.Subtitle; notification.payload.title = notif.Payload.Title; return(notification); }
public void NotificationReceivedHandler(iOS.OSNotification notification) { OneSignal.onPushNotificationReceived(OSNotificationToNative(notification)); }