void OnNotificationReceived(string message) { if (onNotificationReceived != null) { string[] s = message.Split(new string[] { NS }, System.StringSplitOptions.None); NCMBPushPayload payload = new NCMBPushPayload(s [0], s [1], s [2], s [3], s [4], s [5], s [6]); onNotificationReceived(payload); } }
void ProcessNotification() { // Payload data dictionary IDictionary dd = UnityEngine.iOS.NotificationServices.remoteNotifications [0].userInfo; // Payload key list string[] kl = new string[] { "com.nifcloud.mbaas.PushId", "com.nifcloud.mbaas.Data", "com.nifcloud.mbaas.Title", "com.nifcloud.mbaas.Message", "com.nifcloud.mbaas.Channel", "com.nifcloud.mbaas.Dialog", "com.nifcloud.mbaas.RichUrl", }; // Payload value list string[] vl = new string[kl.Length]; // Index of com.nifcloud.mbaas.Message int im = 0; // Loop list for (int i = 0; i < kl.Length; i++) { // Get value by key, return empty string if not exist vl [i] = (dd.Contains(kl [i])) ? dd [kl [i]].ToString() : string.Empty; // Find index of com.nifcloud.mbaas.Message im = (kl [i] == "com.nifcloud.mbaas.Message") ? i : im; } // Set message as alertBody if (string.IsNullOrEmpty(vl [im])) { vl [im] = UnityEngine.iOS.NotificationServices.remoteNotifications [0].alertBody; } // Create payload NCMBPushPayload pl = new NCMBPushPayload(vl [0], vl [1], vl [2], vl [3], vl [4], vl [5], vl [6], UnityEngine.iOS.NotificationServices.remoteNotifications [0].userInfo); // Notify if (onNotificationReceived != null) { onNotificationReceived(pl); } }
void Update() { #if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 if (NotificationServices.remoteNotificationCount > 0) { #else if (UnityEngine.iOS.NotificationServices.remoteNotificationCount > 0) { #endif ProcessNotification(); NCMBPush push = new NCMBPush(); push.ClearAll(); } } void ProcessNotification() { // Payload data dictionary #if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 IDictionary dd = NotificationServices.remoteNotifications [0].userInfo; #else IDictionary dd = UnityEngine.iOS.NotificationServices.remoteNotifications [0].userInfo; #endif // Payload key list string[] kl = new string[] { "com.nifty.PushId", "com.nifty.Data", "com.nifty.Title", "com.nifty.Message", "com.nifty.Channel", "com.nifty.Dialog", "com.nifty.RichUrl", }; // Payload value list string[] vl = new string[kl.Length]; // Index of com.nifty.Message int im = 0; // Loop list for (int i = 0; i < kl.Length; i++) { // Get value by key, return empty string if not exist vl [i] = (dd.Contains(kl [i])) ? dd [kl [i]].ToString() : string.Empty; // Find index of com.nifty.message im = (kl [i] == "com.nifty.Message") ? i : im; } // Set message as alertBody if (string.IsNullOrEmpty(vl [im])) { #if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 vl [im] = NotificationServices.remoteNotifications [0].alertBody; #else vl [im] = UnityEngine.iOS.NotificationServices.remoteNotifications [0].alertBody; #endif } // Create payload #if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 NCMBPushPayload pl = new NCMBPushPayload(vl [0], vl [1], vl [2], vl [3], vl [4], vl [5], vl [6], NotificationServices.remoteNotifications [0].userInfo); #else NCMBPushPayload pl = new NCMBPushPayload(vl [0], vl [1], vl [2], vl [3], vl [4], vl [5], vl [6], UnityEngine.iOS.NotificationServices.remoteNotifications [0].userInfo); #endif // Notify if (onNotificationReceived != null) { onNotificationReceived(pl); } } void OnApplicationPause(bool pause) { if (!pause) { ClearAfterOneFrame(); } } void ClearAfterOneFrame() { StartCoroutine(IEClearAfterAFrame()); } IEnumerator IEClearAfterAFrame() { yield return(0); NCMBPush push = new NCMBPush(); push.ClearAll(); }
void OnNotificationReceived(string message) { if (onNotificationReceived != null) { string[] s = message.Split(new string[] { NS }, System.StringSplitOptions.None); NCMBPushPayload payload = new NCMBPushPayload(s[0], s[1], s[2], s[3], s[4], s[5], s[6]); onNotificationReceived(payload); } }
void ProcessNotification() { // Payload data dictionary IDictionary dd = NotificationServices.remoteNotifications[0].userInfo; // Payload key list string[] kl = new string[] { "com.nifty.PushId", "com.nifty.Data", "com.nifty.Title", "com.nifty.Message", "com.nifty.Channel", "com.nifty.Dialog", "com.nifty.RichUrl", }; // Payload value list string[] vl = new string[kl.Length]; // Index of com.nifty.Message int im = 0; // Loop list for (int i = 0; i < kl.Length; i++) { // Get value by key, return empty string if not exist vl[i] = (dd.Contains(kl[i])) ? dd[kl[i]].ToString() : string.Empty; // Find index of com.nifty.message im = (kl[i] == "com.nifty.Message") ? i : im; } // Set message as alertBody if (string.IsNullOrEmpty(vl[im])) { vl[im] = NotificationServices.remoteNotifications[0].alertBody; } // Create payload NCMBPushPayload pl = new NCMBPushPayload(vl[0], vl[1], vl[2], vl[3], vl[4], vl[5], vl[6], NotificationServices.remoteNotifications[0].userInfo); // Notify if (onNotificationReceived != null) { onNotificationReceived(pl); } }
void Update () { #if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 if (NotificationServices.remoteNotificationCount > 0) { #else if (UnityEngine.iOS.NotificationServices.remoteNotificationCount > 0) { #endif ProcessNotification (); NCMBPush push = new NCMBPush (); push.ClearAll (); } } void ProcessNotification () { // Payload data dictionary #if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 IDictionary dd = NotificationServices.remoteNotifications [0].userInfo; #else IDictionary dd = UnityEngine.iOS.NotificationServices.remoteNotifications [0].userInfo; #endif // Payload key list string[] kl = new string[] { "com.nifty.PushId", "com.nifty.Data", "com.nifty.Title", "com.nifty.Message", "com.nifty.Channel", "com.nifty.Dialog", "com.nifty.RichUrl", }; // Payload value list string[] vl = new string[kl.Length]; // Index of com.nifty.Message int im = 0; // Loop list for (int i = 0; i < kl.Length; i++) { // Get value by key, return empty string if not exist vl [i] = (dd.Contains (kl [i])) ? dd [kl [i]].ToString () : string.Empty; // Find index of com.nifty.message im = (kl [i] == "com.nifty.Message") ? i : im; } // Set message as alertBody if (string.IsNullOrEmpty (vl [im])) { #if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 vl [im] = NotificationServices.remoteNotifications [0].alertBody; #else vl [im] = UnityEngine.iOS.NotificationServices.remoteNotifications [0].alertBody; #endif } // Create payload #if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 NCMBPushPayload pl = new NCMBPushPayload (vl [0], vl [1], vl [2], vl [3], vl [4], vl [5], vl [6], NotificationServices.remoteNotifications [0].userInfo); #else NCMBPushPayload pl = new NCMBPushPayload (vl [0], vl [1], vl [2], vl [3], vl [4], vl [5], vl [6], UnityEngine.iOS.NotificationServices.remoteNotifications [0].userInfo); #endif // Notify if (onNotificationReceived != null) { onNotificationReceived (pl); } } void OnApplicationPause (bool pause) { if (!pause) { ClearAfterOneFrame (); } } void ClearAfterOneFrame () { StartCoroutine (IEClearAfterAFrame ()); } IEnumerator IEClearAfterAFrame () { yield return 0; NCMBPush push = new NCMBPush (); push.ClearAll (); }