예제 #1
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);
        }
 public void NotificationReceived(Android.OSNotification notification)
 {
     (OneSignal.Current as OneSignalImplementation).OnPushNotificationReceived(NotificationOpenedHandler.OSNotificationToNative(notification));
 }
예제 #3
0
 public void NotificationReceived(Android.OSNotification notification)
 {
     OneSignal.onPushNotificationReceived(OSNotificationToNative(notification));
 }