Forum Xamarin.iOS


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Xamarin iOS: Issue with using latest version of Facebook API

ASyedASyed USMember ✭✭
edited August 2016 in Xamarin.iOS

Hi everyone. I recently updated the facebook api for Xamarin iOS : "Xamarin.Facebook.iOS" version="4.13.1"

Latest FB login API has three parameters

public unsafe virtual void LogInWithReadPermissions (string[] permissions, UIViewController fromViewController, [BlockProxy (typeof(Trampolines.NIDLoginManagerRequestTokenHandler))] LoginManagerRequestTokenHandler handler)
I am using MVVMCross. For fb login, I tried created an instance of the view i am in, and pass it as a parameter for LogInWithReadPermissions()


private async void DoFacebookSignIn() { try { await facebookService. Login(); DoAutoLogin(); } }

private readonly string[] permissions = new string[] { "email", "public_profile" };

public async System.Threading.Tasks.Task LogIn()

LoginManager.LogInWithReadPermissionsAsync (permissions);
LoginManagerLoginResult result = await LogInWithReadPermissionsAsync();

            if (result.IsCancelled)
                ServiceFactory.UserMessageService.ShowToast("Facebook login is canceled");

    private Task<LoginManagerLoginResult> LogInWithReadPermissionsAsync()
            var tcs = new TaskCompletionSource<LoginManagerLoginResult> ();
            var vc = new FbSign();
            LoginManager.LogInWithReadPermissions (permissions,vc, //I tried passing null in place of vc
    (LoginManagerLoginResult result, NSError error) =>
                if(error.IsNotNull ())
                    tcs.SetException (new IosErrorException(error));
                } else 
                    tcs.SetResult (result);

            return tcs.Task;

When i run this app is crashing without throwing exceptions. Can any one advice or help me with this issue ?

Best Answer


  • IsaacThomasIsaacThomas USMember

    My app is crashing with FB login too, but it's throwing an NSErrorException when the LoginWithReadPermissionsAsync method is called (and the facebook login completes successfully). Can you post some log data so we can see the issue better?

  • SgXam15SgXam15 INMember ✭✭

    Hi @IsaacThomas were you able to cross this hiatus?I am stuck with a similar situation wherein I am receiving AccessToken.currentaccesstoken as a null even after logging in Facebook using Sharedialog.I need accesstoken as I have to implement graph Api.Any suggestions??

  • IsaacThomasIsaacThomas USMember
    HI SgXam15, I'm not familiar with share dialog, but I retrieved AccessToken.CurrentAccessToken in the OnSuccess() method of the Facebook login interface. Assuming that you did that (because retrieving AccessToken.CurrentAccessToken means the token has been returned from a successful login, as you know), make sure you do the necessary initialization for Facebook in the FinishedLaunching method of AppDelegate.cs as shown here:
  • rmenezesrmenezes BRMember ✭✭

    @ASyed did you solve your problem? I have the same issue in my application.

  • ASyedASyed USMember ✭✭

    @rmenezes Yes.

    You need to whitelist the Observers in info.plist

  • DeanZhuoDeanZhuo Member ✭✭

    done the whitelist and all, but my app still crash at sharing pic. what should i do?

Sign In or Register to comment.