Hi there -
First-time PlayFab user switching from Braincloud chiefly because of this support community :)
I am working in Unity on a mobile game where some back-end features need to be accessible to all users (for example, login time and global variables) while others are reserved for Facebook-authenticated users only (for example, leaderboards).
Currently, I authenticate from the Start() function, like so:
void Start () { var request = new LoginWithIOSDeviceIDRequest { DeviceId = SystemInfo.deviceUniqueIdentifier, CreateAccount = true, TitleId = "XXX" }; PlayFabClientAPI.LoginWithIOSDeviceID(request, PlayFabLoginSuccess, PlayFabLoginError, null, null); }
I then have another script that checks whether the user has logged in with Facebook and, if so, authenticates with PlayFab using Facebook credentials:
private void Start() { if (!FB.IsInitialized) { FB.Init(onInitComplete: FBInitCallBack); } else { FB.ActivateApp(); } } oid FBInitCallBack() { FB.ActivateApp(); if (FB.IsLoggedIn) { OnFacebookLogin(); AuthenticateBCWithFacebook(); } } public void AuthenticateBCWithFacebook() { var request = new LoginWithFacebookRequest { AccessToken = AccessToken.CurrentAccessToken.TokenString, TitleId = "F248", CreateAccount = true }; PlayFabClientAPI.LoginWithFacebook(request, null, null, null, null); }
Unfortunately, this leads to situations where PlayFab treats the same user as two different users - one who authenticated with their DeviceID and another who authenticated with their Facebook account.
How do I avoid this duplication? I've been thinking about simply checking whether the user is logged into Facebook first and, if so, authenticating with Facebook and, if not, authenticating with the device ID - would that solve it?