question

kelvin avatar image
kelvin asked

Logging in with Google when Google Play Games is not installed

Hi,

I'm able to login with Google Play Services following the blog post from PlayFab (https://blog.playfab.com//blog/setting-up-google-sign-in). However I have a question regarding logging in when the user does not have Google Play Games (GPG) application installed. In my game, when I try to log in with out GPG installed, it will prompt me to install GPG.

However, after installing the GPG and returning to my game, Social.localuser.Authenticate will return false. Is there a way to prompt GPG to install before calling Social.localuser.Authenticate?

What I'm trying to do in my game is to first login with Google and then login to Playfab with Google. If they do not have GPG installed then login into Playfab with DeviceId. However, if they choose to install GPG before logging into PlayFab, I want to login to Playfab with Google when I return to the game.

Right now it'll login to Playfab with DeviceId even after installing GPG and returning to the game. I have to close the game and reopen the game before I can login to PlayFab with Google.

Thanks.

-Kelvin

Authentication
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

·
marcowilliamspf avatar image
marcowilliamspf answered

You can do this from any startup point that you would like. I would suggest before you init any Push Feature or even using any Authentication Feature from PlayFab.

var _playServicesUtils = new AndroidJavaClass("com.playfab.unityplugin.GCM.PlayServicesUtils");
_playServicesUtils.CallStatic<bool>("isPlayServicesAvailable");

This will check to see if the device has Google Play Services installed, if it is not installed it will prompt them to allow installation.

Unfortunately there is a downside to this. There is no callback from Google Play Services to notify unity that the installation of Google Play Services has been installed. This means that you will need to poll for it's availability every 30 seconds or so, to check and see if it has been successfully installed. I have not tried this, and it might re-prompt for installation ( i'm not sure how smart this feature is of Google Play Services ).

Another option, is to immediately pop a window in your game that tells them to re-start the app after google play services has completed installation. (ugly flow, but works well)

2 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.

kelvin avatar image kelvin commented ·

Thanks for the response.

I tried adding that code to a button method for testing purposes and nothing happens when I press the button. I looked further into Google's documentation and they say that method is also deprecated so I tried the code below as well and didn't have any luck.

var _playServicesUtils = newAndroidJavaClass("com.google.android.gms.common.GoogleApiAvailability");

playServicesUtils.CallStatic<bool>("isGooglePlayServicesAvailable");

I'm not really sure what else I'm missing. Am I using this correctly?

From my code before I was only able to get the "Install Google Play Games" prompt to pop up when I called Social.localuser.Authenticate().

0 Likes 0 ·
marcowilliamspf avatar image marcowilliamspf kelvin commented ·

our code is just a wrapper around googles actual API. However, this is not a PlayFab issue. This is a Google Play issue.

I would suggest to look into:https://developers.google.com/android/reference/com/google/android/gms/common/GooglePlayServicesUtil

If that doesn't help you, you might need to install the actual Google Play Services unity plugin along side our push notification plugin.

https://github.com/playgameservices/play-games-plugin-for-unity

I know that these work together as you have to use this in order to use Google Sign-in.

Hope this info helps.

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.