question

mooldi avatar image
mooldi asked

Playfab work randomly on iOS, some times player data get loaded, some times not!

Playfab stop randomly on IOS devices iOS12, iPhone 7Plus, unity 5.6.6, PlayFab v0 and in PlayFab v2.
What happens is when I try to request a user data some times I get nothing back, Null object

Here is my code :

IPromise StartLoginPromises() { return new Promise((resolve, reject) => { Debug.LogError("starting promises in StartLoginPromises "); LinkFacebookAccount(fbk.accessToken) .Then(() => { SetPlayerPropretiesReady(); Debug.LogError("SetPlayerPropretiesReady() => Done"); } ) .Then(() => { LoadUserData(); Debug.LogError("LoadUserData() => Done"); } ) .Then(() => { GetCatalogItems(); Debug.LogError("GetCatalogItems() => Done"); } ) .Then(() => { GetStoreItems(); Debug.LogError("GetStoreItems() => Done"); } ) // .Then(() => CallCloudMethod("GrantItems", "4", "12", "59", "58", "0", // "55", "44", "36", "51", "3", "17", "18", "19", "23", "24", "25", "33", "34", // "35", "40", "41", "42", "43", "6", "7", "8", "9")) .Then(() => { GetInventoryItems(); Debug.LogError("GetInventoryItems() => Done"); } ) .Then(() => { ActivePFB(); Debug.LogError("ActivePFB() => Done"); } ) .Done(() => { resolve(); Debug.LogError("resolve() => Done"); } ); }); }


Here is what the LoadUserData() method look like:

private IPromise LoadUserData() { var promise = new Promise(); LoadingState = _loadingstate.LOADING_DATA; GetUserDataRequest request = new GetUserDataRequest() { PlayFabId = playfabid, };

PlayFabClientAPI.GetUserData(request, (result) => { Debug.Log("Got user data:"); if ((result.Data == null) || (result.Data.Count == 0)) { Debug.Log("No user data available"); } else { FillPlayerPropretiesData(properties, result.Data); } promise.Resolve(); }, (error) => { Debug.Log("error from LoadUserData : " + error.ErrorMessage); Exception excep = new Exception("error from LoadUserData : " + error.ErrorMessage); excep.Data.Add(error.HttpCode, error); promise.Reject(excep);

}); return promise;

}

Please answer this question, I was about to release my game

unity3d
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
JayZuo avatar image
JayZuo answered

I'm not sure what the "IPromise" is. It seems you are using some third party libraries. For how to use PlayFab SDK with Unity, you can refer to Unity Getting Started. And to get player data, you can use code like the following:

private void OnLoginSuccess(LoginResult result)
{
    Debug.Log("Congratulations, you made your first successful API call!");
 
    GetUserDataRequest request = new GetUserDataRequest();
    PlayFabClientAPI.GetUserData(request,
        Result =>
        {
            Debug.Log("Got user data:");
            if ((Result.Data == null) || (Result.Data.Count == 0))
            {
                Debug.Log("No user data available");
            }
            else
            {
                foreach (var item in Result.Data)
                {
                    Debug.Log(item.Key + " : " + item.Value.Value);
                }
            }
        },
        Error => { Debug.Log("error from LoadUserData : " + Error.GenerateErrorReport()); });
}

This should always work. Beside, to see if this is a PlayFab issue or Unity code issue, you can use Postman to test these APIs. If you can get right response form Postman, then PlayFab service is OK, you may have some issue in your code.

3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

mooldi avatar image mooldi commented ·

I don't know why you approved this answer, the GetPlayerData API works randomly on mobile ios,

Guys check it there is something is not right, it used to work perfectly one month ago!!!

0 Likes 0 ·
brendan avatar image brendan mooldi commented ·

Because the last part of the answer is the most salient. If you're seeing a problem with a particular API call, the first thing you'll want to try is making it from Postman, or a similar tool. The calls in question are Web API calls - the service doesn't see a difference between the call as made from an iOS device versus an Android, PC, or console. They're exactly the same - simple REST-like calls. If you're having trouble on a particular platform, that's going to be due to something on the local device, so I'd put in a breakpoint to get the specifics of the actual call being made, so that you can test it in Postman.

One possibility would be something was introduced into the Unity SDK we provide. But the SDK does go through testing before release and we didn't run into issues, and I'd expect to see more people saying they're encountering issues if that was the case.

Also, one clarifying question for you: What do "PlayFab v0" and "PlayFab v2" refer to? Those aren't related to any of our SDK version numbers, and we don't use API versioning. Speaking of which, what version of our Unity SDK are you using?

1 Like 1 ·
mooldi avatar image mooldi brendan commented ·

Hi Brendan,

Thank you for your meaningful answer, I did update my SDK to the last one, and The thing is I always modify the API to get a CatalogItem<T> due to my specific architecture.
I'm still not sure why but the problem seems to be fixed.
I'll let you know if anything comes up.

Thank you,
Mouldi

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.