Пример #1
0
        //(Android/iOS)-NCMBManager.onAnalyticsReceived-this.NCMBAnalytics
        internal static void TrackAppOpened(string _pushId)
        {
            //ネイティブから取得したpushIdからリクエストヘッダを作成
            if (_pushId != null && NCMBManager._token != null && NCMBSettings.UseAnalytics) {

                string deviceType = "";
                if (SystemInfo.operatingSystem.IndexOf ("Android") != -1) {
                    deviceType = "android";
                } else if (SystemInfo.operatingSystem.IndexOf ("iPhone") != -1) {
                    deviceType = "ios";
                }

                //RESTリクエストデータ生成
                Dictionary<string,object> requestData = new Dictionary<string,object> {
                    { "pushId", _pushId },
                    { "deviceToken", NCMBManager._token },
                    { "deviceType", deviceType }
                };

                var json = Json.Serialize (requestData);
                string url = CommonConstant.DOMAIN_URL + "/" + CommonConstant.API_VERSION + "/push/" + _pushId + "/openNumber";
                ConnectType type = ConnectType.POST;
                string content = json.ToString ();
                NCMBDebug.Log ("content:" + content);
                //ログを確認(通信前)
                NCMBDebug.Log ("【url】:" + url + Environment.NewLine + "【type】:" + type + Environment.NewLine + "【content】:" + content);
                // 通信処理
                NCMBConnection con = new NCMBConnection (url, type, content, NCMBUser._getCurrentSessionToken ());
                con.Connect (delegate(int statusCode, string responseData, NCMBException error) {
                    try {
                        NCMBDebug.Log ("【StatusCode】:" + statusCode + Environment.NewLine + "【Error】:" + error + Environment.NewLine + "【ResponseData】:" + responseData);
                    } catch (Exception e) {
                        error = new NCMBException (e);
                    }
                    return;
                });

                #if UNITY_IOS
                    #if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7
                    NotificationServices.ClearRemoteNotifications ();
                    #else
                    UnityEngine.iOS.NotificationServices.ClearRemoteNotifications ();
                    #endif
                #endif

            }
        }
Пример #2
0
        private static void _ncmbLogIn(string name, string password, string email, NCMBCallback callback)
        {
            string url = _getLogInUrl ();//URL作成
            ConnectType type = ConnectType.GET;
            //set username, password
            NCMBUser logInUser = new NCMBUser ();

            logInUser.Password = password;

            //nameがあればLogInAsync経由 無ければLogInWithMailAddressAsync経由、どちらも無ければエラー
            if (name != null) {
                logInUser.UserName = name;
            } else if (email != null) {
                logInUser.Email = email;
            } else {
                throw new NCMBException (new ArgumentException ("UserName or Email can not be null."));
            }

            string content = logInUser._toJSONObjectForSaving (logInUser.StartSave ());
            Dictionary<string, object> paramDic = (Dictionary<string, object>)MiniJSON.Json.Deserialize (content);
            url = _makeParamUrl (url + "?", paramDic);
            //ログを確認(通信前)
            NCMBDebug.Log ("【url】:" + url + Environment.NewLine + "【type】:" + type + Environment.NewLine + "【content】:" + content);
            //通信処理
            NCMBConnection con = new NCMBConnection (url, type, content, NCMBUser._getCurrentSessionToken ());
            con.Connect (delegate(int statusCode , string responseData, NCMBException error) {
                try {
                    NCMBDebug.Log ("【StatusCode】:" + statusCode + Environment.NewLine + "【Error】:" + error + Environment.NewLine + "【ResponseData】:" + responseData);
                    if (error != null) {
                        NCMBDebug.Log ("[DEBUG AFTER CONNECT] Error: " + error.ErrorMessage);
                    } else {
                        Dictionary<string, object> responseDic = MiniJSON.Json.Deserialize (responseData) as Dictionary<string, object>;
                        logInUser._handleFetchResult (true, responseDic);
                        //save Current user
                        _saveCurrentUser (logInUser);

                    }
                } catch (Exception e) {
                    error = new NCMBException (e);
                }
                if (callback != null) {
                    Platform.RunOnMainThread (delegate {
                        callback (error);
                    });
                }
                return;
            });
        }
Пример #3
0
 internal static void _logOut(NCMBCallback callback)
 {
     string url = _getLogOutUrl ();//URL作成
     ConnectType type = ConnectType.GET;
     string content = null;
     //ログを確認(通信前)
     NCMBDebug.Log ("【url】:" + url + Environment.NewLine + "【type】:" + type + Environment.NewLine + "【content】:" + content);
     //通信処理
     NCMBConnection con = new NCMBConnection (url, type, content, NCMBUser._getCurrentSessionToken ());
     con.Connect (delegate(int statusCode , string responseData, NCMBException error) {
         try {
             NCMBDebug.Log ("【StatusCode】:" + statusCode + Environment.NewLine + "【Error】:" + error + Environment.NewLine + "【ResponseData】:" + responseData);
             if (error != null) {
                 NCMBDebug.Log ("[DEBUG AFTER CONNECT] Error: " + error.ErrorMessage);
             } else {
                 _logOutEvent ();
             }
         } catch (Exception e) {
             error = new NCMBException (e);
         }
         if (callback != null) {
             Platform.RunOnMainThread (delegate {
                 callback (error);
             });
         }
         return;
     });
 }
Пример #4
0
 internal static void _requestPasswordReset(string email, NCMBCallback callback)
 {
     string url = _getRequestPasswordResetUrl ();//URL
     ConnectType type = ConnectType.POST;
     //set username, password
     NCMBUser pwresetUser = new NCMBUser ();
     pwresetUser.Email = email;
     string content = pwresetUser._toJSONObjectForSaving (pwresetUser.StartSave ());
     //ログを確認(通信前)
     NCMBDebug.Log ("【url】:" + url + Environment.NewLine + "【type】:" + type + Environment.NewLine + "【content】:" + content);
     //通信処理
     NCMBConnection con = new NCMBConnection (url, type, content, NCMBUser._getCurrentSessionToken ());
     con.Connect (delegate(int statusCode , string responseData, NCMBException error) {
         try {
             NCMBDebug.Log ("【StatusCode】:" + statusCode + Environment.NewLine + "【Error】:" + error + Environment.NewLine + "【ResponseData】:" + responseData);
             if (error != null) {
                 NCMBDebug.Log ("[DEBUG AFTER CONNECT] Error: " + error.ErrorMessage);
             } else {
                 NCMBDebug.Log ("[DEBUG AFTER CONNECT] Successful: ");
             }
         } catch (Exception e) {
             error = new NCMBException (e);
         }
         if (callback != null) {
             Platform.RunOnMainThread (delegate {
                 callback (error);
             });
         }
         return;
     });
 }
Пример #5
0
        /// <summary>
        /// 非同期処理で指定したメールアドレスに対して、<br/>
        /// 会員登録を行うためのメールを送信するよう要求します。<br/>
        /// 通信結果が必要な場合はコールバックを指定するこちらを使用します。
        /// </summary>
        /// <param name="email">メールアドレス</param>
        /// <param name="callback">コールバック</param>
        public static void RequestAuthenticationMailAsync(string email, NCMBCallback callback)
        {
            new AsyncDelegate (delegate {
                //URL
                string url = _getmailAddressUserEntryUrl ();//URL

                //コンテント
                NCMBUser user = new NCMBUser ();
                user.Email = email;
                string content = user._toJSONObjectForSaving (user.StartSave ());

                //Type
                ConnectType type = ConnectType.POST;

                NCMBConnection con = new NCMBConnection (url, type, content, NCMBUser._getCurrentSessionToken ());
                NCMBDebug.Log ("【url】:" + url + Environment.NewLine + "【type】:" + type + Environment.NewLine + "【content】:" + content);
                con.Connect (delegate(int statusCode , string responseData, NCMBException error) {
                    NCMBDebug.Log ("【StatusCode】:" + statusCode + Environment.NewLine + "【Error】:" + error + Environment.NewLine + "【ResponseData】:" + responseData);
                    if (callback != null) {
                        Platform.RunOnMainThread (delegate {
                            callback (error);
                        });
                    }
                    return;
                });
            }).BeginInvoke ((IAsyncResult r) => {
            }, null);
        }