Example #1
0
        /// <summary>
        /// iOS,Androidそれぞれの端末登録を行う
        /// </summary>
        /// <param name="usePush">true:プッシュ通知有効 false:プッシュ通知無効</param>
        /// <param name="useAnalytics">true:開封通知有効 false:開封通知無効</param>
        /// <param name="androidSenderId">Android SenderId</param>
        /// <param name="getLocation">true:位置情報有効 false:位置情報無効</param>
        private static void RegisterPush(bool usePush, bool useAnalytics, String androidSenderId, bool getLocation = false)
        {
            //Push関連設定
            _usePush         = usePush;
            _useAnalytics    = useAnalytics;
            _androidSenderId = androidSenderId;

            // Register
            if (usePush)
            {
                //Installation基本情報を取得
                NCMBManager.CreateInstallationProperty();
                if (!getLocation)
                {
                    #if UNITY_ANDROID
                    NCMBPush.Register(androidSenderId);
                    #elif UNITY_IOS
                    NCMBPush.Register(useAnalytics);
                    #endif
                }
                else
                {
                    #if UNITY_ANDROID
                    //not Analytics
                    NCMBPush.RegisterWithLocation(androidSenderId);
                    #elif UNITY_IOS
                    NCMBPush.RegisterWithLocation();
                    #endif
                }
            }
        }
        /// <summary>
        /// Registers the push.
        /// </summary>
        /// <param name="usePush">If set to <c>true</c> use push.</param>
        /// <param name="androidSenderId">Android sender identifier.</param>
        /// <param name="getLocation">If set to <c>true</c> get location.</param>
        private static void RegisterPush(bool usePush, String androidSenderId, bool getLocation = false)
        {
            // Sender idを設定
            _androidSenderId = androidSenderId;

            // Register
            if (usePush)
            {
                if (!getLocation)
                {
                                        #if UNITY_ANDROID
                    NCMBPush.Register(androidSenderId);
                                        #elif UNITY_IOS
                    NCMBPush.Register();
                                        #endif
                }
                else
                {
                                        #if UNITY_ANDROID
                    NCMBPush.RegisterWithLocation(androidSenderId);
                                        #elif UNITY_IOS
                    NCMBPush.RegisterWithLocation();
                                        #endif
                }
            }
        }
        IEnumerator IEClearAfterAFrame()
        {
            yield return(0);

            NCMBPush push = new NCMBPush();

            push.ClearAll();
        }
Example #4
0
 void Update()
 {
     if (NotificationServices.remoteNotificationCount > 0)
     {
         ProcessNotification();
         NCMBPush.ClearAll();
     }
 }
 void Update()
 {
     if (UnityEngine.iOS.NotificationServices.remoteNotificationCount > 0)
     {
         ProcessNotification();
         NCMBPush push = new NCMBPush();
         push.ClearAll();
     }
 }
 /// <summary>
 /// 初期設定を行います。
 /// </summary>
 /// <param name="applicationKey">アプリケーションキー</param>
 /// <param name="clientKey">クライアントキー</param>
 private static void Initialize(String applicationKey, String clientKey)
 {
     // アプリケーションキーを設定
     _applicationKey = applicationKey;
     // クライアントキーを設定
     _clientKey = clientKey;
     // Native Initialize
     NCMBPush.Init(applicationKey, clientKey);
 }
Example #7
0
        /// <summary>
        /// <para>FindAsync用レスポンス処理</para>
        /// <para>_mergeFromServerを呼びレスポンスデータ(JSONテキスト)からNCMBObject(リスト)を作成する</para>
        /// </summary>
        private ArrayList _convertFindResponse(Dictionary <string, object> response)
        {
            ArrayList     answer  = new ArrayList();
            List <object> results = (List <object>)response ["results"];

            if (results == null)
            {
                Debug.Log("null results in find response");
            }
            else
            {
                object objectClassName = null;
                string resultClassName = null;
                if (response.TryGetValue("className", out objectClassName))
                {
                    resultClassName = (string)objectClassName;
                }

                if (resultClassName == null)
                {
                    resultClassName = this._className;
                }

                for (int i = 0; i < results.Count; i++)
                {
                    NCMBObject obj = null;
                    if (resultClassName.Equals("user"))
                    {
                        obj = new NCMBUser();
                    }
                    else if (resultClassName.Equals("role"))
                    {
                        obj = new NCMBRole();
                    }
                    else if (resultClassName.Equals("installation"))
                    {
                        obj = new NCMBInstallation();
                    }
                    else if (resultClassName.Equals("push"))
                    {
                        obj = new NCMBPush();
                    }
                    else if (resultClassName.Equals("file"))
                    {
                        obj = new NCMBFile();
                    }
                    else
                    {
                        obj = new NCMBObject(resultClassName);
                    }
                    obj._mergeFromServer((Dictionary <string, object>)results [i], true);
                    answer.Add(obj);
                }
            }
            return(answer);
        }
Example #8
0
        /// <summary>
        /// 各型毎のURL作成
        /// </summary>
        private string _getSearchUrl(string className)
        {
            string url = "";

            if (className == null || className.Equals(""))
            {
                throw new ArgumentException("Not class name error. Please be sure to specify the class name.");
            }
            else if (className.Equals("push"))
            {
                // プッシュ検索API
                url = new NCMBPush()._getBaseUrl();
            }
            else if (className.Equals("installation"))
            {
                // 配信端末検索API
                url = new NCMBInstallation()._getBaseUrl();
            }
            else if (className.Equals("file"))
            {
                // ファイル検索API
                url = new NCMBFile()._getBaseUrl();
            }
            else if (className.Equals("user"))
            {
                // 会員検索API
                //url = new NCMBUser().getBaseUrl(NCMBUser.URL_TYPE_USER);
                url = new NCMBUser()._getBaseUrl();
            }
            else if (className.Equals("role"))
            {
                // ロール検索API
                url = new NCMBRole()._getBaseUrl();
            }
            else
            {
                // オブジェクト検索API
                url = new NCMBObject(_className)._getBaseUrl();
            }
            return(url);
        }
Example #9
0
        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();
        }
Example #10
0
		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 ();
		}