Exemplo n.º 1
0
    public void Start()
    {
        if (string.IsNullOrEmpty(PlayFabSettings.staticSettings.TitleId))
        {
            /*
             * Please change the titleId below to your own titleId from PlayFab Game Manager.
             * If you have already set the value in the Editor Extensions, this can be skipped.
             */
            PlayFabSettings.staticSettings.TitleId = "42";
        }

    #if UNITY_ANDROID
        var androidRequest = new LoginWithAndroidDeviceIDRequest
        {
            AndroidDeviceId = SystemInfo.deviceUniqueIdentifier, CreateAccount = true
        };
        PlayFabClientAPI.LoginWithAndroidDeviceID(androidRequest, OnLoginSuccess, OnLoginFailure);
    #elif UNITY_IOS
        var iosRequest = new LoginWithIOSDeviceIDRequest
        {
            DeviceId = SystemInfo.deviceUniqueIdentifier, CreateAccount = true
        };
        PlayFabClientAPI.LoginWithIOSDeviceID(iosRequest, OnLoginSuccess, OnLoginFailure);
    #else
        var request = new LoginWithCustomIDRequest {
            CustomId = "GettingStartedGuide", CreateAccount = true
        };
        PlayFabClientAPI.LoginWithCustomID(request, OnLoginSuccess, OnLoginFailure);
    #endif
    }
Exemplo n.º 2
0
 public void LocalLogin()
 {
 #if UNITY_ANDROID
     var requestAndroid = new LoginWithAndroidDeviceIDRequest {
         AndroidDevice = ReturnMobileID(), CreateAccount = true
     };
     requestReturned = false;
     loginSuccess    = false;
     PlayFabClientAPI.LoginWithAndroidDeviceID(requestAndroid, OnLoginMobileSuccess, ErrorHandler);
 #endif
 #if UNITY_IOS
     var requestIOS = new LoginWithIOSDeviceIDRequest {
         DeviceId = ReturnMobileID(), CreateAccount = true
     };
     requestReturned = false;
     loginSuccess    = false;
     PlayFabClientAPI.LoginWithIOSDeviceID(requestIOS, OnLoginMobileSuccess, ErrorHandler);
 #endif
 #if UNITY_EDITOR_WIN
     var requestEditor = new LoginWithCustomIDRequest {
         CustomId = "TestPlayFab", CreateAccount = true
     };
     requestReturned = false;
     loginSuccess    = false;
     PlayFabClientAPI.LoginWithCustomID(requestEditor, OnLoginSuccess, ErrorHandler);
 #endif
 #if UNITY_STANDALONE
     var requestStandalone = new LoginWithCustomIDRequest {
         CustomId = "TestPlayFab", CreateAccount = true
     };
     requestReturned = false;
     loginSuccess    = false;
     PlayFabClientAPI.LoginWithCustomID(requestStandalone, OnLoginSuccess, ErrorHandler);
 #endif
 }
    // Start is called before the first frame update
    void Start()
    {
        // Note: Setting title Id here can be skipped if you have set the value in Editor Extensions already.
        if (string.IsNullOrEmpty(PlayFabSettings.staticSettings.TitleId))
        {
            PlayFabSettings.staticSettings.TitleId = "XXXX"; // Please change this value to your own titleId from PlayFab Game Manager
        }
        var deviceId = this.GetDeviceId();

#if UNITY_IPHONE
        var request = new LoginWithIOSDeviceIDRequest {
            DeviceId = deviceId, CreateAccount = true
        };
        PlayFabClientAPI.LoginWithIOSDeviceID(request, OnLoginSuccess, OnLoginFailure);
#elif UNITY_ANDROID
        var request = new LoginWithAndroidDeviceIDRequest {
            DeviceId = deviceId, CreateAccount = true
        };
        PlayFabClientAPI.LoginWithAndroidDeviceID(request, OnLoginSuccess, OnLoginFailure);
#else
        var request = new LoginWithCustomIDRequest {
            CustomId = deviceId, CreateAccount = true
        };
        PlayFabClientAPI.LoginWithCustomID(request, OnLoginSuccess, OnLoginFailure);
#endif
    }
Exemplo n.º 4
0
    private void DoLogin()
    {
        StartCoroutine(DelayLogin());
        PlayFabSettings.TitleId = GameSettings.I.PlayFabGameId;

#if UNITY_IOS
        var requestIos = new LoginWithIOSDeviceIDRequest
        {
            TitleId       = GameSettings.I.PlayFabGameId,
            DeviceId      = SystemInfo.deviceUniqueIdentifier,
            DeviceModel   = UnityEngine.iOS.Device.generation.ToString(),
            OS            = UnityEngine.iOS.Device.systemVersion,
            CreateAccount = true
        };
        PlayFabClientAPI.LoginWithIOSDeviceID(requestIos, OnLoginSuccess, OnLoginFailure);
#elif UNITY_ANDROID
        var requestAndroid = new LoginWithAndroidDeviceIDRequest
        {
            TitleId         = GameSettings.I.PlayFabGameId,
            AndroidDevice   = SystemInfo.operatingSystem,
            OS              = SystemInfo.operatingSystem,
            AndroidDeviceId = SystemInfo.deviceUniqueIdentifier,
            CreateAccount   = true
        };
        PlayFabClientAPI.LoginWithAndroidDeviceID(requestAndroid, OnLoginSuccess, OnLoginFailure);
#else
        var request = new LoginWithCustomIDRequest
        {
            CustomId      = PlayerData.PlayerId,
            CreateAccount = true
        };
        PlayFabClientAPI.LoginWithCustomID(request, OnLoginSuccess, OnLoginFailure);
#endif
    }
Exemplo n.º 5
0
    public void Start()
    {
        //Note: Setting title Id here can be skipped if you have set the value in Editor Extensions already.
        if (string.IsNullOrEmpty(PlayFabSettings.TitleId))
        {
            PlayFabSettings.TitleId = "8741"; // Please change this value to your own titleId from PlayFab Game Manager
        }
        PlayerPrefs.DeleteAll();
        //var request = new LoginWithCustomIDRequest { CustomId = "GettingStartedGuide", CreateAccount = true };
        //PlayFabClientAPI.LoginWithCustomID(request, OnLoginSuccess, OnLoginFailure);
        if (PlayerPrefs.HasKey("EMAIL"))
        {
            userEmail    = PlayerPrefs.GetString("EMAIL");
            userPassword = PlayerPrefs.GetString("PASSWORD");
            var request = new LoginWithEmailAddressRequest {
                Email = userEmail, Password = userPassword
            };
            PlayFabClientAPI.LoginWithEmailAddress(request, OnLoginSuccess, OnLoginFailure);
        }
        else
        {
#if UNITY_ANDROID
            var requestAndroid = new LoginWithAndroidDeviceIDRequest {
                AndroidDeviceId = ReturnMobileID(), CreateAccount = true
            };
            PlayFabClientAPI.LoginWithAndroidDeviceID(requestAndroid, OnLoginMobileSuccess, OnLoginMobileFailure);
#endif
#if UNITY_IOS
            var requestIOS = new LoginWithIOSDeviceIDRequest {
                DeviceId = ReturnMobileID(), CreateAccount = true
            };
            PlayFabClientAPI.LoginWithIOSDeviceID(requestIOS, OnLoginMobileSuccess, OnLoginMobileFailure);
#endif
        }
    }
Exemplo n.º 6
0
 private void LogInWithIOSID(bool create)
 {
     Debug.Log("Login with IOS ID");
     if (!proceed)
     {
         proceed = true;
         //LoadingCanvas.enabled = true;
         ShowLoading();
         ShowCanvas(null);
         LoginWithIOSDeviceIDRequest        request       = new LoginWithIOSDeviceIDRequest();
         GetPlayerCombinedInfoRequestParams playerRequest = new GetPlayerCombinedInfoRequestParams();
         playerRequest.GetPlayerProfile = true;
         request.InfoRequestParameters  = playerRequest;
         request.CreateAccount          = create;
         request.DeviceId = SystemInfo.deviceUniqueIdentifier;
         request.TitleId  = PlayFabSettings.TitleId;
         //add to request OS and model
         if (create)
         {
             PlayFabClientAPI.LoginWithIOSDeviceID(request, LoginWithAccountCreated, OnPlayFabError);
         }
         else
         {
             PlayFabClientAPI.LoginWithIOSDeviceID(request, OnLoginSuccess, OnPlayFabError);
         }
     }
 }
Exemplo n.º 7
0
    public void LoginToPlayFab(string playerCustomId)
    {
        Debug.Log("Logging into PlayFab...");
        ShowConnectingLayer();
        menuManager.infoPanels[3].action = "Login";

        GetPlayerCombinedInfoRequestParams playerInfoRequest = new GetPlayerCombinedInfoRequestParams();

        playerInfoRequest.GetUserData = true;

        #if UNITY_EDITOR
        LoginWithCustomIDRequest request = new LoginWithCustomIDRequest();
        request.CustomId              = playerCustomId;
        request.CreateAccount         = false;
        request.InfoRequestParameters = playerInfoRequest;

        PlayFabClientAPI.LoginWithCustomID(request, OnPlayFabLoginSuccess, OnPlayFabLoginError);
        #elif UNITY_IOS
        LoginWithIOSDeviceIDRequest request = new LoginWithIOSDeviceIDRequest();
        request.DeviceId              = playerCustomId;
        request.OS                    = SystemInfo.operatingSystem;
        request.DeviceModel           = SystemInfo.deviceModel;
        request.CreateAccount         = false;
        request.InfoRequestParameters = playerInfoRequest;

        PlayFabClientAPI.LoginWithIOSDeviceID(request, OnPlayFabLoginSuccess, OnPlayFabLoginError);
        #endif
    }
Exemplo n.º 8
0
    public void TransferPlayFabAccount(string playerCustomId)
    {
        Debug.Log("Attempting to transfer account...");
        ShowConnectingLayer();
        menuManager.infoPanels[3].action           = "Transfer";
        menuManager.infoPanels[3].transferPasscode = playerCustomId;

        GetPlayerCombinedInfoRequestParams playerInfoRequest = new GetPlayerCombinedInfoRequestParams();

        playerInfoRequest.GetUserAccountInfo = true;
        playerInfoRequest.GetUserData        = true;

        #if UNITY_EDITOR
        LoginWithCustomIDRequest request = new LoginWithCustomIDRequest();
        request.CustomId              = playerCustomId;
        request.CreateAccount         = false;
        request.InfoRequestParameters = playerInfoRequest;

        PlayFabClientAPI.LoginWithCustomID(request, OnTransferSuccess, OnTransferError);
        #elif UNITY_IOS
        LoginWithIOSDeviceIDRequest request = new LoginWithIOSDeviceIDRequest();
        request.DeviceId              = playerCustomId;
        request.OS                    = SystemInfo.operatingSystem;
        request.DeviceModel           = SystemInfo.deviceModel;
        request.CreateAccount         = false;
        request.InfoRequestParameters = playerInfoRequest;

        PlayFabClientAPI.LoginWithIOSDeviceID(request, OnTransferSuccess, OnTransferError);
        #endif
    }
Exemplo n.º 9
0
    public void Start()
    {
        if (string.IsNullOrEmpty(PlayFabSettings.staticSettings.TitleId))
        {
            /*
             * Please change the titleId below to your own titleId from PlayFab Game Manager.
             * If you have already set the value in the Editor Extensions, this can be skipped.
             */
            PlayFabSettings.staticSettings.TitleId = titleID;
        }
        if (PlayerPrefs.HasKey(PlayerPrefsEmail) && PlayerPrefs.HasKey(PlayerPrefsPassWord))
        {
            GetLoginData();
            var request = new LoginWithEmailAddressRequest {
                Email = userEmail, Password = userPassWord
            };
            PlayFabClientAPI.LoginWithEmailAddress(request, OnLoginSuccess, OnLoginFailure);
        }
        else
        {
#if UNITY_ANDROID
            var requestAndroid = new LoginWithAndroidDeviceIDRequest {
                AndroidDeviceId = ReturnMobileID(), CreateAccount = true
            };
            PlayFabClientAPI.LoginWithAndroidDeviceID(requestAndroid, OnLoginMobileSuccess, OnLoginMobileFailure);
#endif

#if UNITY_IOS
            var requestIOS = new LoginWithIOSDeviceIDRequest {
                DeviceId = ReturnMobileID(), CreateAccount = true
            };
            PlayFabClientAPI.LoginWithIOSDeviceID(requestIOS, OnLoginMobileSuccess, OnLoginMobileFailure);
#endif
        }
    }
    public void Start()
    {
        if (string.IsNullOrEmpty(PlayFabSettings.staticSettings.TitleId))
        {
            PlayFabSettings.staticSettings.TitleId = "B5400";
        }

        if (PlayerPrefs.HasKey("NICKNAME"))
        {
            nickname = PlayerPrefs.GetString("NICKNAME");

            var requestAndroid = new LoginWithAndroidDeviceIDRequest {
                AndroidDeviceId = ReturnMobileID(), CreateAccount = true
            };
            PlayFabClientAPI.LoginWithAndroidDeviceID(requestAndroid, OnLoginAndroidSuccess, OnLoginAndroidFailure);
        }
        else
        {
#if UNITY_ANDROID
            var requestAndroid = new LoginWithAndroidDeviceIDRequest {
                AndroidDeviceId = ReturnMobileID(), CreateAccount = true
            };
            PlayFabClientAPI.LoginWithAndroidDeviceID(requestAndroid, OnLoginAndroidSuccess, OnLoginAndroidFailure);
#endif
#if UNITY_IOS
            var requestIOS = new LoginWithIOSDeviceIDRequest {
                DeviceId = ReturnMobileID(), CreateAccount = true
            };
            PlayFabClientAPI.LoginWithIOSDeviceID(requestIOS, OnLoginIOSSuccess, OnLoginIOSFailure);
#endif
        }
    }
Exemplo n.º 11
0
        public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req,
            ILogger log)
        {
            string requestBody = await new StreamReader(req.Body).ReadToEndAsync();

            try
            {
                LoginWithIOSDeviceIDRequest requestFromDevice = JsonConvert.DeserializeObject <LoginWithIOSDeviceIDRequest>(requestBody);
                PlayFabSettings.TitleId                 = "6D64";
                requestFromDevice.CreateAccount         = true;
                requestFromDevice.InfoRequestParameters = new GetPlayerCombinedInfoRequestParams
                {
                    GetUserData = true
                };

                var loginTask = await PlayFabClientAPI.LoginWithIOSDeviceIDAsync(requestFromDevice);

                Console.WriteLine(JsonConvert.SerializeObject(loginTask));


                return((ActionResult) new OkObjectResult(JsonConvert.SerializeObject(loginTask)));
            }
            catch (Exception ex)
            {
                log.LogError($"Failure to log in: {ex}");
                return(new BadRequestObjectResult($"Error logging in: {ex}"));
            }
        }
    /// <summary>
    /// Tests attempts to use device identifier as a valid login credentials. If the device has been used before this will succeed, otherwise fail.
    /// </summary>
    public static void TestDeviceIdHasAccount()
    {
        if (GetDeviceId())
        {
            LoginMethodUsed = LoginPathways.deviceId;
            if (!string.IsNullOrEmpty(android_id))
            {
                Debug.Log("Testing Android Device ID: " + android_id);
                LoginWithAndroidDeviceIDRequest request = new LoginWithAndroidDeviceIDRequest();
                request.AndroidDeviceId = android_id;
                request.TitleId         = PlayFabSettings.TitleId;
                request.CreateAccount   = false;

                PlayFabClientAPI.LoginWithAndroidDeviceID(request, OnLoginResult, OnTestDeviceIdHasAccountError);
            }
            else if (!string.IsNullOrEmpty(ios_id))
            {
                Debug.Log("Testing IOS Device ID: " + ios_id);
                LoginWithIOSDeviceIDRequest request = new LoginWithIOSDeviceIDRequest();
                request.DeviceId      = ios_id;
                request.TitleId       = PlayFabSettings.TitleId;
                request.CreateAccount = false;

                PlayFabClientAPI.LoginWithIOSDeviceID(request, OnLoginResult, OnTestDeviceIdHasAccountError);
            }
        }
    }
Exemplo n.º 13
0
        public void Authenticate(string i_id)
        {
            MyMessenger.Instance.Send <LogTypes, string, string>(MyLogger.LOG_EVENT, LogTypes.Info, "Authentication attempt for title " + TITLE_ID, PLAYFAB);

            PlayFabSettings.TitleId = TITLE_ID;

#if UNITY_EDITOR
            LoginWithCustomIDRequest request = new LoginWithCustomIDRequest()
            {
                TitleId       = TITLE_ID,
                CreateAccount = true,
                CustomId      = i_id
            };

            PlayFabClientAPI.LoginWithCustomID(request, (result) => {
                UnityEngine.Debug.LogError("Logged in with playfab id " + result.PlayFabId);
                mPlayFabId     = result.PlayFabId;
                mSessionTicket = result.SessionTicket;

                IAuthenticationSuccess successResult = null;
                MyMessenger.Instance.Send <IAuthenticationSuccess>(BackendMessages.AUTH_SUCCESS, successResult);
            },
                                               (error) => { HandleError(error, BackendMessages.AUTH_FAIL); });
#elif UNITY_ANDROID
            LoginWithAndroidDeviceIDRequest request = new LoginWithAndroidDeviceIDRequest()
            {
                TitleId         = TITLE_ID,
                CreateAccount   = true,
                AndroidDeviceId = SystemInfo.deviceUniqueIdentifier,
            };

            PlayFabClientAPI.LoginWithAndroidDeviceID(request, (result) => {
                UnityEngine.Debug.LogError("Logged in with playfab id " + result.PlayFabId);
                mPlayFabId     = result.PlayFabId;
                mSessionTicket = result.SessionTicket;

                IAuthenticationSuccess successResult = null;
                MyMessenger.Instance.Send <IAuthenticationSuccess>(BackendMessages.AUTH_SUCCESS, successResult);
            },
                                                      (error) => { HandleError(error, BackendMessages.AUTH_FAIL); });
#elif UNITY_IOS
            LoginWithIOSDeviceIDRequest request = new LoginWithIOSDeviceIDRequest()
            {
                TitleId       = TITLE_ID,
                CreateAccount = true,
                DeviceId      = SystemInfo.deviceUniqueIdentifier
            };

            PlayFabClientAPI.LoginWithIOSDeviceID(request, (result) => {
                UnityEngine.Debug.LogError("Logged in with playfab id " + result.PlayFabId);
                mPlayFabId     = result.PlayFabId;
                mSessionTicket = result.SessionTicket;

                IAuthenticationSuccess successResult = null;
                MyMessenger.Instance.Send <IAuthenticationSuccess>(BackendMessages.AUTH_SUCCESS, successResult);
            },
                                                  (error) => { HandleError(error, BackendMessages.AUTH_FAIL); });
#endif
        }
Exemplo n.º 14
0
    void Start()
    {
        if (!PlayFabClientAPI.IsClientLoggedIn())
        {
            var infoRequestParameters = new GetPlayerCombinedInfoRequestParams()
            {
                GetPlayerProfile   = true,
                ProfileConstraints = new PlayerProfileViewConstraints()
                {
                    ShowDisplayName = true
                }
            };

#if !UNITY_EDITOR && UNITY_IOS
            string deviceId = UnityEngine.iOS.Device.vendorIdentifier;
            var    request  = new LoginWithIOSDeviceIDRequest {
                DeviceId              = deviceId,
                CreateAccount         = true,
                InfoRequestParameters = infoRequestParameters
            };
            PlayFabClientAPI.LoginWithIOSDeviceID(request, OnLoginSuccess, OnError);
#else
            string customId;
            if (!PlayerPrefs.HasKey("customId"))
            {
                Guid guid = Guid.NewGuid();
                customId = guid.ToString();
                PlayerPrefs.SetString("customId", customId);
            }
            else
            {
                customId = PlayerPrefs.GetString("customId");
            }

            var request = new LoginWithCustomIDRequest {
                CustomId              = customId,
                CreateAccount         = true,
                InfoRequestParameters = infoRequestParameters
            };
            PlayFabClientAPI.LoginWithCustomID(request, OnLoginSuccess, OnError);
#endif
        }
        else
        {
            if (string.IsNullOrEmpty(DisplayName))
            {
                PlayFabClientAPI.GetPlayerProfile(new GetPlayerProfileRequest()
                {
                    ProfileConstraints = new PlayerProfileViewConstraints()
                    {
                        ShowDisplayName = true
                    }
                }, OnGetProfileSuccess, OnError);
            }
        }
    }
Exemplo n.º 15
0
 void MobileLogin()
 {
     if (Application.platform == RuntimePlatform.Android)
     {
         var requestAndroid = new LoginWithAndroidDeviceIDRequest {
             AndroidDeviceId = GetMobileID(), CreateAccount = true
         };
         PlayFabClientAPI.LoginWithAndroidDeviceID(requestAndroid, result =>
         {
             Debug.Log("login was a success");
             GameData.data.PlayfabLogin = true;
             EndLogin();
         }, PlayFabError =>
         {
             GameData.data.PlayfabLogin = false;
             EndLogin();
         });
     }
     else if (Application.platform == RuntimePlatform.IPhonePlayer)
     {
         var requestIOS = new LoginWithIOSDeviceIDRequest {
             DeviceId = GetMobileID(), CreateAccount = true
         };
         PlayFabClientAPI.LoginWithIOSDeviceID(requestIOS, result =>
         {
             Debug.Log("login was a success");
             GameData.data.PlayfabLogin = true;
             EndLogin();
         }, PlayFabError =>
         {
             GameData.data.PlayfabLogin = false;
             EndLogin();
         });
     }
     else
     {
         var requestEditor = new LoginWithIOSDeviceIDRequest {
             DeviceId = GetMobileID(), CreateAccount = true
         };
         PlayFabClientAPI.LoginWithIOSDeviceID(requestEditor, result =>
         {
             Debug.Log("login was a success");
             GameData.data.PlayfabLogin = true;
             EndLogin();
         }, PlayFabError =>
         {
             GameData.data.PlayfabLogin = false;
             EndLogin();
         });
     }
 }
Exemplo n.º 16
0
    private void LoginToPlayFab()
    {
#if UNITY_ANDROID
        var request = new LoginWithAndroidDeviceIDRequest {
            AndroidDeviceId = SystemInfo.deviceUniqueIdentifier, CreateAccount = true,
        };
        PlayFabClientAPI.LoginWithAndroidDeviceID(request, OnPfLogin, OnPfFail);
#elif UNITY_IOS
        var request = new LoginWithIOSDeviceIDRequest {
            DeviceId = SystemInfo.deviceUniqueIdentifier, CreateAccount = true,
        };
        PlayFabClientAPI.LoginWithIOSDeviceID(request, OnPfLogin, OnPfFail);
#endif
    }
        public override void OnEnter()
        {
            PlayFabSettings.TitleId = titleId.Value;

            var request = new LoginWithIOSDeviceIDRequest()
            {
                TitleId       = titleId.Value,
                DeviceId      = UnityEngine.SystemInfo.deviceUniqueIdentifier,
                DeviceModel   = UnityEngine.SystemInfo.deviceModel,
                OS            = UnityEngine.SystemInfo.operatingSystem,
                CreateAccount = true
            };

            PlayFabClientAPI.LoginWithIOSDeviceID(request, OnLoginSucces, OnLoginFailure);
        }
Exemplo n.º 18
0
    //creates a PlayFab account if one doesn't exist for this device
    public void CreateMobileDeviceGuest()
    {
#if UNITY_ANDROID
        var requestAndroid = new LoginWithAndroidDeviceIDRequest {
            AndroidDeviceId = ReturnMobileID(), CreateAccount = true
        };
        PlayFabClientAPI.LoginWithAndroidDeviceID(requestAndroid, OnCreateLoginGuestSuccess, OnCreateLoginGuestFailure);
#endif
#if UNITY_IOS
        var requestIOS = new LoginWithIOSDeviceIDRequest {
            DeviceId = ReturnMobileID(), CreateAccount = true
        };
        PlayFabClientAPI.LoginWithIOSDeviceID(requestIOS, OnLoginGuestSuccess, OnLoginGuestFailure);
#endif
    }
Exemplo n.º 19
0
    private void FrictionlessLoginMobileDevice()
    {
#if UNITY_ANDROID
        var requestAndroid = new LoginWithAndroidDeviceIDRequest {
            AndroidDeviceId = ReturnMobileID(), CreateAccount = false
        };
        PlayFabClientAPI.LoginWithAndroidDeviceID(requestAndroid, OnFrictionlessLoginMobileSuccess, OnFrictionlessLoginMobileFailure);
#endif
#if UNITY_IOS
        var requestIOS = new LoginWithIOSDeviceIDRequest {
            DeviceId = ReturnMobileID(), CreateAccount = false
        };
        PlayFabClientAPI.LoginWithIOSDeviceID(requestIOS, OnFrictionlessLoginMobileSuccess, OnFrictionlessLoginMobileFailure);
#endif
    }
Exemplo n.º 20
0
    public void Start()
    {
        //Note: Setting title Id here can be skipped if you have set the value in Editor Extensions already.
        if (string.IsNullOrEmpty(PlayFabSettings.TitleId))
        {
            PlayFabSettings.TitleId = "AFAC0"; // Please change this value to your own titleId from PlayFab Game Manager
        }
        //      var request = new LoginWithCustomIDRequest { CustomId = "GettingStartedGuide", CreateAccount = true };
        //      PlayFabClientAPI.LoginWithCustomID(request, OnLoginSuccess, OnLoginFailure);


        //      PlayerPrefs.DeleteAll();


        if (PlayerPrefs.HasKey("EMAIL"))
        {
            // "If our EMAIL key exists, then most likely, our PASSWORD key will exist as well
            //  because we are setting those player preferences at the same time...  So if the EMAIL exists,
            //  then we want to take the EMAIL and the PASSWORD and put them int thier variables..."
            //          Not sure I follow.  I will follow up.
            //
            //Upon Review...  This should check for the PW also.

            userEmail    = PlayerPrefs.GetString("EMAIL");
            userPassword = PlayerPrefs.GetString("PASSWORD");
            var request = new LoginWithEmailAddressRequest {
                Email = userEmail, Password = userPassword
            };
            PlayFabClientAPI.LoginWithEmailAddress(request, OnLoginSuccess, OnLoginFailure);
        }
        else
        {
#if UNITY_ANDROID
            var requestAndroid = new LoginWithAndroidDeviceIDRequest {
                AndroidDeviceId = ReturnMobileID(), CreateAccount = true
            };
            PlayFabClientAPI.LoginWithAndroidDeviceID(requestAndroid, OnLoginMobileSuccess, OnLoginMobileFailure);
#endif

#if UNITY_IOS
            var requestIOS = new LoginWithIOSDeviceIDRequest {
                DeviceId = ReturnMobileID(), CreateAccount = true
            };
            PlayFabClientAPI.LoginWithIOSDeviceID(requestIOS, OnLoginMobileSuccess, OnLoginMobileFailure);
#endif
        }
    }
Exemplo n.º 21
0
        private void HandleiOSDeviceIdLoginMethod(Action <LoginResult> loginSuccess, Action <PlayFabError> loginFailure, bool linkGameService = false)
        {
            var request = new LoginWithIOSDeviceIDRequest {
                DeviceId = SystemInfo.deviceUniqueIdentifier, CreateAccount = true
            };

            PlayFabClientAPI.LoginWithIOSDeviceID(request, (LoginResult loginResult) => { OnPlayerLogin(loginResult); loginSuccess.Invoke(loginResult); IsLogged = true; PlayFabId = loginResult.PlayFabId; }, (PlayFabError e) => loginFailure.Invoke(e));
            GameData.Current.LoginType = LoginType.Device;

            if (linkGameService)
            {
                var requestLink = new LinkGameCenterAccountRequest()
                {
                    GameCenterId = GameServiceManager.GameService.PlayerId
                };
                PlayFabClientAPI.LinkGameCenterAccount(requestLink, (LinkGameCenterAccountResult r) => { GameData.Current.LoginType = LoginType.GameService; }, (PlayFabError e) => loginFailure.Invoke(e));
            }
        }
Exemplo n.º 22
0
    private async void Login()
    {
#if UNITY_IOS
        var request = new LoginWithIOSDeviceIDRequest()
        {
            CreateAccount = true,
            DeviceId      = SystemInfo.deviceUniqueIdentifier
        };

        var result = await PlayFabClientAPI.LoginWithIOSDeviceIDAsync(request);

        if (result.Error != null)
        {
            Debug.LogError(result.Error.GenerateErrorReport());
        }
        else
        {
            Debug.Log("Logged in");

            // Refresh available items
            RefreshIAPItems();
        }
#elif UNITY_ANDROID
        var request = new LoginWithAndroidDeviceIDRequest()
        {
            CreateAccount   = true,
            AndroidDeviceId = SystemInfo.deviceUniqueIdentifier
        };
        var result = await PlayFabClientAPI.LoginWithAndroidDeviceIDAsync(request);

        if (result.Error != null)
        {
            Debug.LogError(result.Error.GenerateErrorReport());
        }
        else
        {
            Debug.Log("Logged in");
            text.text = "Logged in";

            // Refresh available items
            RefreshIAPItems();
        }
#endif
    }
Exemplo n.º 23
0
    public void Start()
    {
#if UNITY_ANDROID
        var request = new LoginWithAndroidDeviceIDRequest {
            AndroidDeviceId = ReturnMobileID(), CreateAccount = true
        };
        PlayFabClientAPI.LoginWithAndroidDeviceID(request, OnLoginSuccess, OnLoginFailure);
#elif UNITY_IOS
        var request = new LoginWithIOSDeviceIDRequest {
            DeviceId = ReturnMobileID(), CreateAccount = true
        };
        PlayFabClientAPI.LoginWithIOSDeviceID(request, OnLoginSuccess, OnLoginFailure);
#else
        var request = new LoginWithCustomIDRequest {
            CustomId = ReturnMobileID(), CreateAccount = true
        };
        PlayFabClientAPI.LoginWithCustomID(request, OnLoginSuccess, OnLoginFailure);
#endif
    }
Exemplo n.º 24
0
    public void Start()
    {
        //Note: Setting title Id here can be skipped if you have set the value in Editor Extensions already.
        if (string.IsNullOrEmpty(PlayFabSettings.TitleId))
        {
            PlayFabSettings.TitleId = "4F74A"; // Please change this value to your own titleId from PlayFab Game Manager
        }

        PlayerPrefs.DeleteAll();    // For testing

        /* Used for testing, use a valid way to verify accounts!
         * var request = new LoginWithCustomIDRequest { CustomId = "GettingStartedGuide", CreateAccount = true};
         * PlayFabClientAPI.LoginWithCustomID(request, OnLoginSuccess, OnLoginFailure);
         */

        if (PlayerPrefs.HasKey("EMAIL"))
        {
            userEmail    = PlayerPrefs.GetString("EMAIL");
            userPassword = PlayerPrefs.GetString("PASSWORD");
            var request = new LoginWithEmailAddressRequest {
                Email = userEmail, Password = userPassword
            };
            PlayFabClientAPI.LoginWithEmailAddress(request, OnLoginSuccess, OnLoginFailure);    // Send in our request, and what to do if it passes/fails
        }
        else
        {
#if UNITY_ANDROID
            // NOTE: This will look greyed out in our IDE if we aren't on the target platform in the build settings
            // Register the account via the device ID automatically
            var requestAndroid = new LoginWithAndroidDeviceIDRequest {
                AndroidDeviceId = ReturnMobileID(), CreateAccount = true
            };
            PlayFabClientAPI.LoginWithAndroidDeviceID(requestAndroid, OnLoginMobileSuccess, OnLoginMobileFailure);
#endif

#if UNITY_IOS
            var requestIOS = new LoginWithIOSDeviceIDRequest {
                DeviceId = ReturnMobileID(), CreateAccount = true
            };
            PlayFabClientAPI.LoginWithIOSDeviceID(requestIOS, OnLoginMobileSuccess, OnLoginMobileFailure);
#endif
        }
    }
Exemplo n.º 25
0
    public void Start()
    {
        loginPanel.SetActive(false);
        RecoveryButton.SetActive(false);
        RecoveryLoginPanel.SetActive(false);
        //Note: Setting title Id here can be skipped if you have set the value in Editor Extensions already.
        if (string.IsNullOrEmpty(PlayFabSettings.TitleId))
        {
            PlayFabSettings.TitleId = "C14AC"; // Please change this value to your own titleId from PlayFab Game Manager
        }

        if (PlayerPrefs.HasKey("EMAIL"))
        {
            if (autoLogin)
            {
                userEmail    = PlayerPrefs.GetString("EMAIL");
                userPassword = PlayerPrefs.GetString("PASSWORD");
                var request = new LoginWithEmailAddressRequest {
                    Email = userEmail, Password = userPassword
                };
                PlayFabClientAPI.LoginWithEmailAddress(request, OnLoginSuccess, OnLoginFailure);
            }
        }
        else
        {
#if UNITY_ANDROID
            var requestAndroid = new LoginWithAndroidDeviceIDRequest {
                AndroidDeviceId = ReturnMobileID(), CreateAccount = true
            };
            PlayFabClientAPI.LoginWithAndroidDeviceID(requestAndroid, OnMobileLoginSuccess, OnMobileLoginFailure);
            RecoveryButton.SetActive(true);
#elif UNITY_IOS
            var requestIos = new LoginWithIOSDeviceIDRequest {
                DeviceId = ReturnMobileID(), CreateAccount = true
            };
            PlayFabClientAPI.LoginWithIOSDeviceID(requestIos, OnMobileLoginSuccess, OnMobileLoginFailure);
            RecoveryButton.SetActive(true);
#else
            loginPanel.SetActive(true);
#endif
        }
    }
Exemplo n.º 26
0
    public void GuestLogin()
    {
        //todo: auto try to connect to local containers --> Delete this later
        //TestQuickLocalLogin();
        LoginCustomId();
        // we will use device id on android and IOS to log in instead
#if UNITY_ANDROID
        var reqAnd = new LoginWithAndroidDeviceIDRequest {
            AndroidDeviceId = GetMobileDeviceID(), CreateAccount = true
        };
        PlayFabClientAPI.LoginWithAndroidDeviceID(reqAnd, MobileLoginSuccess, MobileLoginFailed);
#endif

#if UNITY_IOS
        var reqIos = new LoginWithIOSDeviceIDRequest {
            DeviceId = GetMobileDeviceID(), CreateAccount = true
        };
        PlayFabClientAPI.LoginWithIOSDeviceID(reqIos, MobileLoginSuccess, MobileLoginFailed);
#endif
    }
Exemplo n.º 27
0
    void Connect()
    {
        if (string.IsNullOrEmpty(PlayFabSettings.TitleId))
        {
            PlayFabSettings.TitleId = "5555"; // Please change this value to your own titleId from PlayFab Game Manager
        }


#if UNITY_ANDROID
        var requestAndroid = new LoginWithAndroidDeviceIDRequest {
            AndroidDeviceId = ReturnMobileID(), CreateAccount = true
        };
        PlayFabClientAPI.LoginWithAndroidDeviceID(requestAndroid, OnLoginMobileSuccess, OnLoginMobileFailure);
#endif
#if UNITY_IOS
        var requestIOS = new LoginWithIOSDeviceIDRequest {
            DeviceId = ReturnMobileID(), CreateAccount = true
        };
        PlayFabClientAPI.LoginWithIOSDeviceID(requestIOS, OnLoginMobileSuccess, OnLoginMobileFailure);
#endif
    }
Exemplo n.º 28
0
 public void LogInPlayFabDeviceID()
 {
     if (Application.platform == RuntimePlatform.Android)
     {
         var request = new LoginWithAndroidDeviceIDRequest {
             AndroidDeviceId = SystemInfo.deviceUniqueIdentifier
         };
         PlayFabClientAPI.LoginWithAndroidDeviceID(request, OnLogInDeviceIDSuccess, OnLogInDeviceIDFailure);
     }
     else if (Application.platform == RuntimePlatform.IPhonePlayer)
     {
         var request = new LoginWithIOSDeviceIDRequest {
             DeviceId = SystemInfo.deviceUniqueIdentifier
         };
         PlayFabClientAPI.LoginWithIOSDeviceID(request, OnLogInDeviceIDSuccess, OnLogInDeviceIDFailure);
     }
     else if (Application.platform == RuntimePlatform.WindowsEditor)
     {
         //This is Unity Editor so log in Bitch!!!
         DebugText.text += "\nThis is Unity Device";
         LogInWindow.SetActive(true);
     }
 }
Exemplo n.º 29
0
    public void CreatePlayFabAccount(string playerCustomId, string playerName)
    {
        Debug.Log("Creating account...");
        ShowConnectingLayer();
        menuManager.infoPanels[3].action     = "Create";
        menuManager.infoPanels[3].playerName = playerName;

        #if UNITY_EDITOR
        LoginWithCustomIDRequest request = new LoginWithCustomIDRequest();
        request.CustomId      = playerCustomId;
        request.CreateAccount = true;

        PlayFabClientAPI.LoginWithCustomID(request, OnCreateSuccess, OnCreateError, playerName, null);
        #elif UNITY_IOS
        LoginWithIOSDeviceIDRequest request = new LoginWithIOSDeviceIDRequest();
        request.DeviceId      = playerCustomId;
        request.OS            = SystemInfo.operatingSystem;
        request.DeviceModel   = SystemInfo.deviceModel;
        request.CreateAccount = true;

        PlayFabClientAPI.LoginWithIOSDeviceID(request, OnCreateSuccess, OnCreateError, playerName, null);
        #endif
    }
Exemplo n.º 30
0
        public override void OnEnter()
        {
            PlayFabSettings.TitleId = titleId.Value;

#if UNITY_IOS
            var request = new LoginWithIOSDeviceIDRequest()
            {
                TitleId       = titleId.Value,
                DeviceId      = SystemInfo.deviceUniqueIdentifier,
                DeviceModel   = SystemInfo.deviceModel,
                OS            = SystemInfo.operatingSystem,
                CreateAccount = true
            };

            PlayFabClientAPI.LoginWithIOSDeviceID(request, OnLoginSucces, OnLoginFailure);
#elif UNITY_ANDROID
            var request = new LoginWithAndroidDeviceIDRequest()
            {
                TitleId         = titleId.Value,
                AndroidDeviceId = SystemInfo.deviceUniqueIdentifier,
                AndroidDevice   = SystemInfo.deviceModel,
                OS            = SystemInfo.operatingSystem,
                CreateAccount = true
            };

            PlayFabClientAPI.LoginWithAndroidDeviceID(request, OnLoginSucces, OnLoginFailure);
#elif UNITY_STANDALONE
            var request = new LoginWithCustomIDRequest()
            {
                TitleId       = titleId.Value,
                CustomId      = UnityEngine.SystemInfo.deviceUniqueIdentifier,
                CreateAccount = true
            };

            PlayFabClientAPI.LoginWithCustomID(request, OnLoginSucces, OnLoginFailure);
#endif
        }