Beispiel #1
0
            /// <summary>
            /// AddCallback and return a callback id.
            /// </summary>
            /// <param name="callback">Action<string></param>
            /// <returns>an uint</returns>
            public static uint AddCallback(Action <string> callback)
            {
                // Add a callback if did not initialized.
                if (!isInit)
                {
                    ExecuteInvoke.NCMBAppleAuth_HandlerCallback(ExecuteInvoke.HandlerCallback);
                    isInit = true;
                }

                // throw an exception: can't add a null callback.
                if (callback == null)
                {
                    throw new Exception("Callback is null.");
                }

                var currentCallbackId = default(uint);

                lock (SyncLock)
                {
                    currentCallbackId = callbackId;
                    callbackId       += 1;
                    if (callbackId >= uint.MaxValue)
                    {
                        callbackId = 1U;
                    }

                    var callbackEntry = new ActionEntry(callback);
                    CallbackDictionary.Add(currentCallbackId, callbackEntry);
                }
                return(currentCallbackId);
            }
Beispiel #2
0
        /// <summary>
        /// Method call iOS native login with apple id.
        /// </summary>
        /// <param name="successCallback">return a NCMBAppleCredential after iOS native login with apple id successful.</param>
        /// <param name="errorCallback">return a NCMBAppleError after iOS native login with apple id failure.</param>
        public void NCMBiOSNativeLoginWithAppleId(Action <NCMBAppleCredential> successCallback,
                                                  Action <NCMBAppleError> errorCallback)
        {
#if (UNITY_IOS || UNITY_TVOS) && !UNITY_EDITOR
            var requestId = ControlCallbackAction.AddCallback(
                payloadResponse =>
            {
                var response = JsonUtility.FromJson <NCMBAppleResponse>(payloadResponse);
                if (response.Error != null)
                {
                    errorCallback(response.Error);
                }
                else
                {
                    successCallback(response.NCMBAppleCredential);
                }
            });

            ExecuteInvoke.NCMBAppleAuth_LoginWithAppleId(requestId);
#endif
        }