23 thoughts on “Facebook native login with Xamarin.Forms

  1. Daniel , obrigado por compartilhar!
    Só tenho uma dúvida, para implementar sem Prism? Na MainViewModel, recebe-se como parâmetros um FbManager, o que é necessário passar para ela?

    Liked by 1 person

    1. Entao, essa classe FacebookManager, e injetada na ViewModel pelo container de DI que eu usei nesse projeto(Unity) que ja vem com o Prism. Voce pode injetar essa classe na tua viewmodel com o container de DI que usar no seu projeto.

      Like

  2. Hey Daniel,
    Thanks for the amazing efforts man, really helpful.
    i’m following your article to implement fb login on android and ios
    I’m getting a problem installing facebook sdk on the Android project.
    it conflicts with the Xamarin Forms library, I always get this error

    Version conflict detected for Xamarin.Android.Support.Compat. Reference the package directly from the project to resolve this issue.
    testApp.Android -> Xamarin.Forms 2.5.0.91635 -> Xamarin.Android.Support.v7.MediaRouter 25.4.0.2 -> Xamarin.Android.Support.v7.Palette 25.4.0.2 -> Xamarin.Android.Support.Compat (= 25.4.0.2)
    testApp.Android -> Xamarin.Facebook.Android 4.26.0 -> Xamarin.Android.Support.CustomTabs 25.3.1 -> Xamarin.Android.Support.Compat (= 25.3.1).

    and I’ve been on this for a while now and I can’t seem to find any common compat library between the two libraries.
    any ideas?

    Like

    1. Hey! Have you tried to make the code in the repo run, using your own configurations?

      Does your project run without the Facebook SDK? I’m not realy sure how to work around this since I can’t reproduce it on my end.

      if you find a way around this, please post here or on the repo issues on git hub! So we can keep track of it and help others that may have the same problem!

      Like

    2. You must use older packages: Xamarin.Forms 2.4.xx, Xamarin.Android.Support.Compat. I had same problem with Xamarin.Forms.Maps.

      Like

  3. Hey Amr,

    I found exactly the same problem. Stumped me for ages. However, eventually I realized that Xamarin.Android.Support.CustomTabs 26.1.0.1 (I’ve bound to Oreo in my project) has been pulled in as a dependency automated (I hadn’t installed it manually).

    To get round this problem, I had to go to Nuget and install Xamarin.Android.Support.CustomTabs manually (with the same version that is already installed). After doing that, when I went to Xamarin.Facebook.Android package and was able to install it.

    The weird thing is:

    Xamarin.Facebook.Android 4.26.0 – > Xamarin.Android.Support.Compat 25.3.1 as displayed in the error message issued by nuget is misleading. If you look at the dependencies list on the Xamarin.Facebook.Android package, i says Xamarin.Android.Support.Compat >=25.3.1 (i.e. greater than or equal to), not = equal to. Not sure why that’s the case, but it doesn’t install without problems.

    Like

  4. Hi Daniel

    First of all I just want to say thank you for the Google And Facebook Native Plugin tutorials. I just wanted to know 2 things which are a bit off the topic and that you might just consider.

    1. Since you have 2 native login methods and the methods with regard to the platform have slightly different implementations, but the viewmodel for the login view is more or less the same regardless of the platform, would it be possible to simplify the viewmodel and have for e.g on Login and one Logout method instead of having GoogleLogin, FacebookLogin, GoogleLogout, FacebookLogout?

    2.Is it possible to call one of the login provider methods from anywhere in an application to find out whether or not a user is logged into a platform before logging them out.

    Thank you sooo much Daniel.

    I’d understand if you feel I’m asking for too much, thank you for your time.

    Like

  5. Hi Daniel
    I’m facing a problem with the Facebook Login for iOS, After I tap the button to login with Facebook, a webview opens and provides me with two options:
    1.Login With Email Or Phone Number
    2.Continue To Facebook Application(Login with Facebook application)
    Well they’re not exactly in those words, but something to that effect.
    After I select the option to login with the Facebook Application and confirm that I want to login, it returns back to my application but the webview with the two login options is still there. The only way the ‘call back’ function is fired is by cancelling the login by tapping on ‘Done’ in the top left of the dialog.

    Like

      1. I had to change my code in the AppDelegate from this:

        public override bool OpenUrl(UIApplication app, NSUrl url, NSDictionary options)
        {
        UIApplicationOpenUrlOptions openUrlOptions = new UIApplicationOpenUrlOptions(options);
        return SignIn.SharedInstance.HandleUrl(url, openUrlOptions.SourceApplication, openUrlOptions.Annotation);
        }

        which is Daniel’s Native Google Login Sample, if my memory serves me correctly

        to this:

        public override bool OpenUrl(UIApplication application, NSUrl url, string sourceApplication, NSObject annotation)
        {
        return ApplicationDelegate.SharedInstance.OpenUrl(application, url, sourceApplication, annotation);
        }

        which is in Daniel’s Facebook Native Login Sample, the above override works for both Google Login And Facebook Login.

        Sorry for replying so late Ryan, I hope this helps you.

        Liked by 1 person

  6. I have another question though I was looking at the iOS code for the facebook login, when you’re assigning a value to the variables for example first_name or last_name, there’s a try catch block for each and every variable, why is this so, why not just have one try catch block for all of them.

    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 )

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s