コード例 #1
0
        void AppDelegate_NotificationReceived(object sender, UserInfoEventArgs e)
        {
            var notificationSection = new Section();
            var apsDictionary       = e.UserInfo ["aps"] as NSDictionary;

            string body;

            if (apsDictionary ["alert"] is NSDictionary)
            {
                var alertDictionary = apsDictionary ["alert"] as NSDictionary;

                if (alertDictionary.ContainsKey(new NSString("title")))
                {
                    notificationSection.Caption = alertDictionary ["title"].ToString();
                }

                body = alertDictionary ["body"].ToString();
            }
            else
            {
                body = apsDictionary ["alert"].ToString();
            }

            notificationSection.Add(new StringElement("Body", body));
            AddCustomData(e.UserInfo, notificationSection);
            Root.Add(notificationSection);
        }
コード例 #2
0
 void AppDelegate_MessageReceived(object sender, UserInfoEventArgs e)
 {
     if (e.MessageType == MessageType.Data)
     {
         HandleDataMessage(e.UserInfo);
     }
     else
     {
         HandleNotificationMessage(e.UserInfo);
     }
 }
コード例 #3
0
        public void DidReceiveNotificationResponse(UNUserNotificationCenter center, UNNotificationResponse response, Action completionHandler)
        {
            if (NotificationReceived == null)
            {
                return;
            }

            var e = new UserInfoEventArgs {
                UserInfo = response.Notification.Request.Content.UserInfo
            };

            NotificationReceived(this, e);
        }
コード例 #4
0
        public void WillPresentNotification(UNUserNotificationCenter center, UNNotification notification, Action <UNNotificationPresentationOptions> completionHandler)
        {
            if (NotificationReceived == null)
            {
                return;
            }

            var e = new UserInfoEventArgs {
                UserInfo = notification.Request.Content.UserInfo
            };

            NotificationReceived(this, e);
        }
コード例 #5
0
        // To receive notifications in foregroung on iOS 9 and below.
        // To receive notifications in background in any iOS version
        public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action <UIBackgroundFetchResult> completionHandler)
        {
            // If you are receiving a notification message while your app is in the background,
            // this callback will not be fired 'till the user taps on the notification launching the application.

            // If you disable method swizzling, you'll need to call this method.
            // This lets FCM track message delivery and analytics, which is performed
            // automatically with method swizzling enabled.
            //Messaging.GetInstance ().AppDidReceiveMessage (userInfo);

            if (NotificationReceived == null)
            {
                return;
            }

            var e = new UserInfoEventArgs {
                UserInfo = userInfo
            };

            NotificationReceived(this, e);
        }
コード例 #6
0
        void HandleMessage(NSDictionary message)
        {
            if (MessageReceived == null)
            {
                return;
            }

            MessageType messageType;

            if (message.ContainsKey(new NSString("aps")))
            {
                messageType = MessageType.Notification;
            }
            else
            {
                messageType = MessageType.Data;
            }

            var e = new UserInfoEventArgs(message, messageType);

            MessageReceived(this, e);
        }