Exemple #1
0
 /*** protected and private methods ****/
         #if ONESIGNAL_PLATFORM
 // Called from the native SDK - Called when a push notification received.
 public static void onPushNotificationReceived(OSNotification notification)
 {
     if (builder._notificationReceivedDelegate != null)
     {
         builder._notificationReceivedDelegate(notification);
     }
 }
Exemple #2
0
        public static OSNotification OSNotificationToNative(Android.OSNotification notif)
        {
            var notification = new OSNotification();

            notification.shown = notif.Shown;
            notification.androidNotificationId = notif.AndroidNotificationId;
            notif.GroupedNotifications         = notif.GroupedNotifications;
            notif.IsAppInFocus = notif.IsAppInFocus;

            notification.payload = new OSNotificationPayload();


            notification.payload.actionButtons = new List <Dictionary <string, object> >();
            if (notif.Payload.ActionButtons != null)
            {
                foreach (Android.OSNotificationPayload.ActionButton button in notif.Payload.ActionButtons)
                {
                    var d = new Dictionary <string, object>();
                    d.Add(button.Id, button.Text);
                    notification.payload.actionButtons.Add(d);
                }
            }

            notification.payload.additionalData = new Dictionary <string, object>();
            if (notif.Payload.AdditionalData != null)
            {
                var iterator = notif.Payload.AdditionalData.Keys();
                while (iterator.HasNext)
                {
                    var key = (string)iterator.Next();
                    notification.payload.additionalData.Add(key, notif.Payload.AdditionalData.Get(key));
                }
            }

            notification.payload.body                 = notif.Payload.Body;
            notification.payload.launchURL            = notif.Payload.LaunchURL;
            notification.payload.notificationID       = notif.Payload.NotificationID;
            notification.payload.sound                = notif.Payload.Sound;
            notification.payload.title                = notif.Payload.Title;
            notification.payload.bigPicture           = notif.Payload.BigPicture;
            notification.payload.fromProjectNumber    = notif.Payload.FromProjectNumber;
            notification.payload.groupMessage         = notif.Payload.GroupKey;
            notification.payload.groupMessage         = notif.Payload.GroupMessage;
            notification.payload.largeIcon            = notif.Payload.LargeIcon;
            notification.payload.ledColor             = notif.Payload.LedColor;
            notification.payload.lockScreenVisibility = notif.Payload.LockScreenVisibility;
            notification.payload.smallIcon            = notif.Payload.SmallIcon;
            notification.payload.smallIconAccentColor = notif.Payload.SmallIconAccentColor;

            return(notification);
        }
Exemple #3
0
        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);
        }