Ejemplo n.º 1
0
        private void OnAuthorizeAttempt(bool i_success, Callback <AccountLinkResultTypes> i_requestCallback, bool i_forceLink = false)
        {
            if (!i_success)
            {
                i_requestCallback(AccountLinkResultTypes.Error);
                return;
            }

            PlayGamesPlatform.Instance.GetServerAuthCode((code, authToken) => {
                PlayFabBackend backend = BackendManager.GetBackend <PlayFabBackend>();
                backend.StartRequest("Linking account with Google with " + authToken);

                LinkGoogleAccountRequest request = new LinkGoogleAccountRequest()
                {
                    ServerAuthCode = authToken,
                    ForceLink      = i_forceLink
                };

                PlayFabClientAPI.LinkGoogleAccount(request,
                                                   (result) => {
                    backend.RequestComplete("LinkAccountToGoogle() complete, success", LogTypes.Info);
                    i_requestCallback(AccountLinkResultTypes.SuccessfulLink);
                },
                                                   (error) => {
                    backend.HandleError(error, "LinkAccountToGoogle() complete, error");
                    switch (error.Error)
                    {
                    case PlayFabErrorCode.AccountAlreadyLinked:
                        i_requestCallback(AccountLinkResultTypes.AlreadyLinked);
                        break;

                    case PlayFabErrorCode.LinkedAccountAlreadyClaimed:
                        i_requestCallback(AccountLinkResultTypes.LinkAlreadyClaimed);
                        break;

                    default:
                        i_requestCallback(AccountLinkResultTypes.Error);
                        break;
                    }
                });
            });
        }
Ejemplo n.º 2
0
        private void HandleAndroidDeviceIdLoginMethod(Action <LoginResult> loginSuccess, Action <PlayFabError> loginFailure, bool mustLinkGooglePlay = false)
        {
#if UNITY_ANDROID
            var request = new LoginWithAndroidDeviceIDRequest {
                AndroidDeviceId = SystemInfo.deviceUniqueIdentifier, CreateAccount = true
            };
            PlayFabClientAPI.LoginWithAndroidDeviceID(request, (LoginResult loginResult) => { OnPlayerLogin(loginResult); loginSuccess.Invoke(loginResult); IsLogged = true; PlayFabId = loginResult.PlayFabId; }, (PlayFabError e) => loginFailure.Invoke(e));
            GameData.Current.LoginType = LoginType.Device;

            if (mustLinkGooglePlay)
            {
                var authCode    = ((GooglePlayGameService)GameServiceManager.GameService).GetServerAuthCode();
                var requestLink = new LinkGoogleAccountRequest()
                {
                    ServerAuthCode = authCode
                };
                PlayFabClientAPI.LinkGoogleAccount(requestLink, (LinkGoogleAccountResult r) => { GameData.Current.LoginType = LoginType.GameService; }, (PlayFabError e) => loginFailure.Invoke(e));
            }
#endif
        }
Ejemplo n.º 3
0
        /*
         * public void HandleDataConflict(MergeConflictRule rule)
         * {
         *  if (rule == MergeConflictRule.UserPrompt) rule = mergeRule;
         *  switch(rule)
         *  {
         *      case MergeConflictRule.UseLocal:
         *          break;
         *
         *      case MergeConflictRule.UseServer:
         *          DBManager.Overwrite(instance.serverData.ToString());
         *          DBManager.GetInstance().Init();
         *          break;
         *
         *      case MergeConflictRule.Custom:
         *          //your own conflict resolution here!
         *          break;
         *  }
         *
         *  IAPManager.GetInstance().Initialize();
         * }
         */


        /// <summary>
        /// Not implemented yet.
        /// </summary>
        public static void LinkAccountNative()
        {
            //if not logged in,
            //ask for platform login

            #if UNITY_ANDROID
            LinkGoogleAccountRequest request = new LinkGoogleAccountRequest()
            {
                ServerAuthCode = "",
                ForceLink      = true
            };
            PlayFabClientAPI.LinkGoogleAccount(request, null, AccountAlreadyLinked);
            #elif UNITY_IOS
            LinkGameCenterAccountRequest request = new LinkGameCenterAccountRequest()
            {
                GameCenterId = "",
                ForceLink    = true
            };
            PlayFabClientAPI.LinkGameCenterAccount(request, null, AccountAlreadyLinked);
            #endif
        }