Exemple #1
0
        private ReceivedNotification ToReceivedNotification(RemoteNotification notification)
        {
            Dictionary <string, string> userData = UserInfoToDictionaryOfStrings(notification.userInfo);

            if (userData != null && userData.ContainsKey(m_idKeyName))
            {
                userData.Remove(m_idKeyName);
            }

            int id = ExtractId(notification.userInfo);

            string title, text;

#if UNITY_2018_2_OR_NEWER
            title = notification.alertTitle;
            text  = notification.alertBody;
#else
            ExtractTitleAndText(notification.alertBody, out title, out text);
#endif

            ReceivedNotification receivedNotification = new ReceivedNotification(title, text, id >= 0 ? id : m_nextPushNotificationId, userData, ExtractNotificationProfile(notification.soundName), notification.applicationIconBadgeNumber);

            if (id < 0 && m_incrementalId)
            {
                ++m_nextPushNotificationId;
            }

            return(receivedNotification);
        }
        public void PushNotification(RemoteNotification notification)
#endif
        {
            try {
                String endpoint = getEndpoint("talk/game/" + swrve.ApiKey + "/user/" + swrve.UserId + "/push");

                if (CanMakePushNotificationRequest())
                {
                    lastPushNotificationRequestTime = SwrveHelper.GetMilliseconds();

                    Dictionary <string, object> pushJson = new Dictionary <string, object>();
                    pushJson.Add("alert", notification.alertBody);
                    pushJson.Add("sound", notification.soundName);
                    pushJson.Add("badge", notification.applicationIconBadgeNumber);

                    if (notification.userInfo != null && notification.userInfo.Contains(PushTrackingKey))
                    {
                        string pushId = notification.userInfo[PushTrackingKey].ToString();
                        pushJson.Add("id", pushId);
                    }

                    MakeRequest(endpoint, pushJson);
                }
            } catch (Exception exp) {
                SwrveLog.LogError("QA request talk session failed: " + exp.ToString());
            }
        }
Exemple #3
0
        #pragma warning restore 0618

        void OnNotificationOpened(RemoteNotification notif)
        {
            message.Value      = notif.content.body;
            actionId.Value     = notif.id;
            isAppInFocus.Value = notif.isAppInForeground;

            var data = notif.content.userInfo;

            if (data != null)
            {
                additionalDataItemCount.Value = data.Count;
                additionalDataKeys.Values     = new object[data.Count];
                additionalDataValues.Values   = new object[data.Count];

                int i = 0;

                foreach (KeyValuePair <string, object> pair in data)
                {
                    additionalDataKeys.Values[i]   = (object)pair.Key;
                    additionalDataValues.Values[i] = (object)pair.Value.ToString();
                    i++;
                }
            }

            Fsm.Event(eventTarget, notificationOpenedEvent);
        }
Exemple #4
0
 void RaiseRemoteNotificationEvent(RemoteNotification notification)
 {
     if (RemoteNotificationOpened != null)
     {
         RemoteNotificationOpened(notification);
     }
 }
 private string Log(RemoteNotification notif)
 {
     return(string.Format("{0},{1},{2},{3}",
                          notif.alertBody,
                          notif.hasAction,
                          notif.applicationIconBadgeNumber,
                          notif.soundName));
 }
Exemple #6
0
 protected void ProcessRemoteNotification(RemoteNotification notification)
 {
     if (config.PushNotificationEnabled)
     {
         ProcessRemoteNotificationUserInfo(notification.userInfo);
         if (PushNotificationListener != null)
         {
             PushNotificationListener.OnRemoteNotification(notification);
         }
         if (qaUser != null)
         {
             qaUser.PushNotification(notification);
         }
     }
 }
Exemple #7
0
 protected void ProcessRemoteNotification(RemoteNotification notification)
 {
     if (config.PushNotificationEnabled)
     {
         ProcessRemoteNotificationUserInfo(notification.userInfo);
         // Do not call listener for silent pushes
         if (notification.userInfo == null || !notification.userInfo.Contains(SilentPushTrackingKey))
         {
             if (config.PushNotificationListener != null)
             {
                 config.PushNotificationListener.OnRemoteNotification(notification);
             }
         }
     }
 }
Exemple #8
0
        IEnumerator CRRaiseEvents(string actionId, NotificationRequest request, bool isForeground, bool isRemote)
        {
            // This could be called at app-launch-from-notification, so we'd better
            // check if the Helper is ready before asking it to schedule a job on main thread.
            while (!Helper.IsInitialized())
            {
                yield return(new WaitForSeconds(0.1f));
            }

            Helper.RunOnMainThread(() =>
            {
                if (isRemote)
                {
                    var delivered = new RemoteNotification(
                        request.id,
                        actionId,
                        request.content,
                        isForeground,
                        isForeground ? false : true
                        );

                    if (RemoteNotificationOpened != null)
                    {
                        RemoteNotificationOpened(delivered);
                    }
                }
                else
                {
                    // Local notification.
                    var delivered = new LocalNotification(
                        request.id,
                        actionId,
                        request.content,
                        isForeground,
                        isForeground ? false : true                     // isOpened
                        );

                    if (LocalNotificationOpened != null)
                    {
                        LocalNotificationOpened(delivered);
                    }
                }
            });
        }
 // Update is called once per frame
 void Update()
 {
     if (NotificationServices.localNotificationCount > 0)
     {
         LocalNotification noti = NotificationServices.localNotifications[NotificationServices.localNotificationCount - 1];
         if (MsgAction != null)
         {
             MsgAction(noti.userInfo);
         }
         NotificationServices.ClearLocalNotifications();
     }
     if (NotificationServices.remoteNotificationCount > 0)
     {
         RemoteNotification noti = NotificationServices.remoteNotifications[NotificationServices.remoteNotificationCount - 1];
         if (MsgAction != null)
         {
             MsgAction(noti.userInfo);
         }
         NotificationServices.ClearRemoteNotifications();
     }
 }
        private static List <Dictionary <string, object> > GetRemoteNotifications()
        {
            List <Dictionary <string, object> > result = new List <Dictionary <string, object> >();

            if (NotificationServices.remoteNotificationCount > 0)
            {
                for (int r = 0; r < NotificationServices.remoteNotificationCount; r++)
                {
                    RemoteNotification remoteNotification = NotificationServices.GetRemoteNotification(r);
                    result.Add(new Dictionary <string, object>()
                    {
                        { "message", remoteNotification.alertBody },
                        { "payload", remoteNotification.userInfo }
                    });
                }
                NotificationServices.ClearRemoteNotifications();
                if (GamedoniaPushNotifications.notificationType == RemoteNotificationType.Badge)
                {
                    ClearBadge();
                }
            }

            return(result);
        }
 public BaseNotificationContentControl HandleNotification(RemoteNotification notification, ref NotificationWindow window)
 {
     return(new BasicSimpleNotificationControl());
 }
Exemple #12
0
 public NotificationWindow(RemoteNotification notification)
 {
     Notification = notification;
 }
Exemple #13
0
 // Push notification opened handler
 void OnPushNotificationOpened(RemoteNotification delivered)
 {
     DisplayNotification(delivered, true);
 }
Exemple #14
0
 private void OnPushNotificationOpened(RemoteNotification delivered)
 {
 }
Exemple #15
0
 public static INotificationManager GetManager(this RemoteNotification notif)
 {
     return(SharedObjects.Instance.GetManagerForIp(notif.SenderAddress));
 }