26 thoughts on “Google native login with Xamarin.Forms

  1. First of all I’d like to say thank you for the sample Daniel, Great Work! I ran the sample app and when I select an account, I always get an alert message that states “an error occured!”

    Liked by 1 person

    1. Hey Sir, thank you! Checkout the type of the error, usually if you got this is because you left something misconfigured, if you are running the Android project, place a break point here(You should be able to see what is the error type and code that google is throwing at you) https://github.com/DanielCauser/SocialLoginSamples/blob/master/GoogleNativeLogin/GoogleNativeLogin/GoogleNativeLogin.Droid/GoogleManager.cs#L59

      If you are debugging the iOS project, place a break point here(Also it is the delegate that gets called by google manager after the login completes)
      https://github.com/DanielCauser/SocialLoginSamples/blob/master/GoogleNativeLogin/GoogleNativeLogin/GoogleNativeLogin.iOS/GoogleManager.cs#L41

      Like

      1. me too, i debug the code, on the protected override void OnActivityResult(int requestCode, Result resultCode, Android.Content.Intent data) the resultCode is Canceled,

        Liked by 1 person

      2. Anggi, make sure you are selecting your google account, Canceled status means you probably miss clicked the google account popup =P

        Like

      3. hi daniel, i make sure that i click my google profile, i even deploy to my real phone, and it still the same error,
        please help me on this,,

        Liked by 1 person

    1. Make sure you have the instance of the google manager being resolved to the static property of the GoogleManager service, you can see it right here: https://github.com/DanielCauser/SocialLoginSamples/blob/master/GoogleNativeLogin/GoogleNativeLogin/GoogleNativeLogin.Droid/GoogleManager.cs#L31

      Also, make sure you are handling the dependency injection on the MainActivity.cs like this example https://github.com/DanielCauser/SocialLoginSamples/blob/master/GoogleNativeLogin/GoogleNativeLogin/GoogleNativeLogin.Droid/MainActivity.cs#L34

      Like

  2. I noticed that when the user has a profile picture, The sign in process is successful, but when you sign in a user without a profile pic, then all the exceptions start, because unlike the iOS project there is no way to check if the PhotoUrl is available or not. I have a solution though. Once again, Thank you Daniel, I really appreciate your assistance.

    Liked by 1 person

  3. Sorry for the late reply Anggi, but if you look in the GoogleManager.cs where the profile photo is set ‘Picture = new Uri(accountt.PhotoUrl.ToString())’, thats where the problem is, here’s a link with a pull requested to the repo that contains the changes I made to the code. Hope this helps 🙂

    Liked by 1 person

  4. Oh and another thing you might want to consider Anggi,don’t change anything when you’re running the sample project provided by Daniel(emphasis on the google-services.json file). The only time you need to change that file is when you’re planning on moving the code into your own project

    Liked by 1 person

    1. That is correct because I have not taken down the APP on my google developer portal hehe. I might just leave it there anyway =P but I encourage people to use this code and follow the configuration steps of the post!

      Like

  5. Obs: If you replace the google-services.json file on the sample project and change the Xamarin.Android package name to yours, the android.

    I do not understand what you mean by this: and change the Xamarin.Android package name to yours

    You can support me

    Liked by 1 person

    1. So, basically what I mean is you are supposed to change the file on the project, by the one you are going to generate for yourself in the google developer portal! After this, you will need to go to the android project properties and change the package name that I have added there, by the one you created on your google developer portal, you can see it in the Step 2 of the section Xamarin Android Project Setup os the post!

      Like

      1. The fact the following:

        1. Download from the github repository
        2. download the json file and replace the one contained in the project
        3. change the package name or also called (package)

        what happens is that the application starts approximately one second and then it does not work

        Like

  6. thank you very much you can compile .. just a query. It is possible to login in another part of my project that is not App.cs, that is, in x.cs page of my project. I’m looking to login after a preview of my application

    Like

    1. Yeah man, you can use this login page wherever you want in your APP, the sample project is a way I figured out of getting the most out of code sharing, you can see that all the calls begin and end on our shared code project, and the target platform projects handle the nuances of login flow.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s