Example #1
0
        // Called when a notification is opened by the user.
        private void HandleOneSignalNotificationOpened(OSNotificationOpenedResult result)
        {
            var delivered = OneSignalHelper.ToCrossPlatformRemoteNotification(result);

            // Fire event
            RaiseRemoteNotificationEvent(delivered);
        }
Example #2
0
        //--------------------------------------------------------
        // OneSignal Event Handlers
        //--------------------------------------------------------
        #if EM_ONESIGNAL
        // Called when your app is in focus and a notification is recieved (no action taken by the user).
        private void HandleOneSignalNotificationReceived(OSNotification notification)
        {
            var delivered = OneSignalHelper.ToCrossPlatformRemoteNotification(null, notification);

            // Fire event
            RaiseRemoteNotificationEvent(delivered);
        }
        //--------------------------------------------------------
        // OneSignal Remote Notification Event Handlers
        //--------------------------------------------------------

        // Called when your app is in focus and a notification is recieved (no action taken by the user).
        private void HandleOneSignalNotificationReceived(OSNotification notification)
        {
            // If isAppInFocus == false, the app was brought to foreground by user opening the notification directly and
            // HandleOneSignalNotificationOpened will be invoked, so we'll ignore such case to prevent firing duplicate events.
            // If isAppInFocus == true, the notification is received when the app is in foreground and not posted to
            // the notification center/system tray (and HandleOneSignalNotificationOpened never gets invoked), so no
            // risk of duplicate events.
            if (notification.isAppInFocus)
            {
                var delivered = OneSignalHelper.ToCrossPlatformRemoteNotification(null, notification);

                // Fire event
                if (RemoteNotificationOpened != null)
                {
                    RemoteNotificationOpened(delivered);
                }
            }
        }