Esempio n. 1
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);
        }
Esempio n. 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;
            });
        }
Esempio n. 3
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;
            });
        }
Esempio n. 4
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;
            });
        }
Esempio n. 5
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;
     });
 }
Esempio n. 6
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);
        }