question

bda2206@gmail.com avatar image
bda2206@gmail.com asked

playfab xamarin integration

I've started again in xamarin, downloaded and installed the PlayFabClientSDK into the studio.

looking at this

https://github.com/PlayFab/Unity3d_Login_Example_Project/blob/master/Assets/PlayFabSamples/Login/Scripts/PlayFabLoginCalls.cs

I thought I would be able to just cut n paste the code across. It doesn't compile, and the result was I had to rejig the API calls region.

for example

 
  /// Login with Facebook token.
  /// </summary>
  /// <param name="token">Token obtained through the FB plugin. (works on mobile and FB canvas only)</param>
  private static void LoginWithFacebook(string token)
  {
  LoginMethodUsed = LoginPathways.facebook;
  LoginWithFacebookRequest request = new LoginWithFacebookRequest();
  request.AccessToken = token;
  request.TitleId = PlayFabSettings.TitleId;
  request.CreateAccount = false;
   
  PlayFabClientAPI.LoginWithFacebook(request, OnLoginResult, OnLoginError);
  }

became

        /// <summary>
        /// Login with Facebook token.
        /// </summary>
        /// <param name="token">Token obtained through the FB plugin. (works on mobile and FB canvas only)</param>
        async Task<Object> LoginWithFacebook(string token)
        {
            LoginMethodUsed = LoginPathways.facebook;
            LoginWithFacebookRequest request = new LoginWithFacebookRequest();
            request.AccessToken = token;
            request.TitleId = PlayFabSettings.TitleId;
            request.CreateAccount = false;

            Object response = await PlayFabClientAPI.LoginWithFacebookAsync(request);

            return response;
             
        }

Is that correct? The API only seems to have Async versions of the calls, with no onSuccess/Onfail parameters.

I thought also perhaps

       async Task<PlayFabResult<LoginResult>> LoginWithFacebook(string token)
        {
            LoginMethodUsed = LoginPathways.facebook;
            LoginWithFacebookRequest request = new LoginWithFacebookRequest();
            request.AccessToken = token;
            request.TitleId = PlayFabSettings.TitleId;
            request.CreateAccount = false;

            PlayFabResult<LoginResult> response = await PlayFabClientAPI.LoginWithFacebookAsync(request);

            return response;
             
        }

but looking at

https://api.playfab.com/Documentation/Client/method/LoginWithFacebook

the response contains

Name Type Description
SessionTicket String Unique token authorizing the user and game at the server level, for the current session.
PlayFabId String Player's unique PlayFabId.
NewlyCreated Boolean True if the account was newly created on this login.
SettingsForUser UserSettings Settings specific to this user.
LastLoginTime DateTime The time of this user's previous login. If there was no previous login, then it's DateTime.MinValue

 

looking at LoginResult in the xamarin Studio shows

namespace PlayFab.ClientModels
{
    public class LoginResult
    {
        //
        // Properties
        //
        public bool NewlyCreated {
            [CompilerGenerated]
            get;
            [CompilerGenerated]
            set;
        }

        public string PlayFabId {
            [CompilerGenerated]
            get;
            [CompilerGenerated]
            set;
        }

        public string SessionTicket {
            [CompilerGenerated]
            get;
            [CompilerGenerated]
            set;
        }

        public UserSettings SettingsForUser {
            [CompilerGenerated]
            get;
            [CompilerGenerated]
            set;
        }

        //
        // Constructors
        //
        public LoginResult ();
    }
}

There is no LastLoginTime parameter.

help!

thanks in advance

 

 

 

10 |1200

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

brendan avatar image
brendan answered

So that everyone has the info - there was indeed an update to the SDK on January 18th that added the LastLoginTime. If you're running into this issue, updating your SDK should resolve it.

10 |1200

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

brendan avatar image
brendan answered

That's odd - LoginResult clearly has LastLoginTime (https://github.com/PlayFab/CSharpSDK/blob/f5cd80b04d6d0229d46ea0fe9a4d9181e3ce4f63/PlayFabClientSDK/source/PlayFabClientModels.cs). Can you send your repro case (the code and specifics on the values used) to us at devrel@playfab.com?

10 |1200

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

bda2206@gmail.com avatar image
bda2206@gmail.com answered

email sent, there's a difference in the PlayFabClientModels file in the downloaded SDK. (13 days old download)

does my async task look like the right rewording of the unity function? 

Is there xamarin example code I can ponder? thanks.

 

10 |1200

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

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.