How do I fix this new Facebook login error?

I am using Xamarin.iOS in Visual Studio, with Xamarin 4.2.0.719, Xamarin.iOS 10.2.04, and the iOS 10 SDK (with Xcode 8). When the facebook login completes successfully, my app throws an NSErrorException. Why is this happening? Has anyone had the same issue, and is there a workaround/fix for it?

Answers

  • DaveHuntDaveHunt USMember ✭✭✭✭✭

    Can you post the complete exception, stacktrace and relevant code? It's kind of hard to debug without more information.

  • IsaacThomasIsaacThomas USMember

    Here is the relevant code:

    loginManager = new LoginManager(); await loginManager.LogInWithReadPermissionsAsync(readPermissions, this);

    The LoginWithReadPermissionsAsync method is the method throwing the exception.

    The stack trace:

    `2016-11-04 06:25:05.020 MyAppiOS[36515:4027733] -canOpenURL: failed for URL: "fbauth2:/" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
    2016-11-04 06:25:05.052 MyAppiOS[36515:4027733] -canOpenURL: failed for URL: "fbauth2:/" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
    Unhandled Exception:

    Foundation.NSErrorException: Exception of type 'Foundation.NSErrorException' was thrown.

    2016-11-04 06:25:53.390 MyApp[36515:4027733]
    Unhandled Exception:
    Foundation.NSErrorException: Exception of type 'Foundation.NSErrorException' was thrown.
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/3859/b638977c/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /Users/builder/data/lanes/3859/b638977c/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/3859/b638977c/source/xamarin-macios/_io
    s-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156
    at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/3859/b638977c/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128
    at System.Runtime.CompilerServices.TaskAwaiter``1[TResult].GetResult () [0x00000] in /Users/builder/data/lanes/3859/b638977c/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:357
    at MyApp.iOS.LoginScreenViewController+d__14.MoveNext () [0x00046] in C:\Users\Me\Apps\MyApp.iOS\MyApp.iOS\View Controllers\LoginScreenViewController.cs:8
    9
    --- End of stack trace from previous location where exception was thrown ---
    at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
    at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/3859/b638977c/source/xamarin-macios/src/UIKit/UIApplication.cs:79
    at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/3859/b638977c/source/xamarin-macios/src/UIKit/UIApplication.cs:63
    at MyApp.iOS.Application.Main (System.String[] args) [0x00001] in C:\Users\Me\Apps\MyApp.iOS\MyApp.iOS\Main.cs:13
    2016-11-04 06:25:53.391 MyAppiOS[36515:4027733] Unhandled managed exception:
    Exception of type 'Foundation.NSErrorException' was thrown. (Foundation.NSErrorException)
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw ()
    [0x0000c] in /Users/builder/data/lanes/3859/b638977c/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /Users/builder/data/lanes/3859/b638977c/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/3859/b638977c/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156
    at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Thread
    ing.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/3859/b638977c/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128
    at System.Runtime.CompilerServices.TaskAwaiter 1[TResult].GetResult () [0x00000] in /Users/builder/data/lanes/3859/b638977c/source/xamarin-macios/_ios-build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:357
    at MyApp.iOS.LoginScreenViewController+d__14.MoveNext () [0x00046] in C:\Users\Me\Apps\MyApp.iOS\MyApp.iOS\View Controllers\LoginScreenViewController.cs:89
    --- End of stack trace from previous location where exception was thrown ---
    at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
    at UIKit.UIApplication.Main (System.String[] args,
    System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/3859/b638977c/source/xamarin-macios/src/UIKit/UIApplication.cs:79
    at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/3859/b638977c/source/xamarin-macios/src/UIKit/UIApplication.cs:63
    at MyApp.iOS.Application.Main (System.String[] args) [0x00001] in C:\Users\Me\Apps\MyApp.iOS\MyApp.iOS\Main.cs:13`

  • DaveHuntDaveHunt USMember ✭✭✭✭✭

    The error message indicates it couldn't find the application you're trying to start up (FaceBook presumably). Do you have the FaceBook app installed? Also, check your app permissions and make sure all the necessary capabilities/entitlements are set correctly.

  • IsaacThomasIsaacThomas USMember
    edited November 2016

    Thanks for the feedback! Well the weird thing is when the button to log into Facebook is clicked, the app logs into facebook (successfully) through a web flow (I'm using the ios simulator). It's after the login has been completed in the webflow, the exception is thrown.

  • DaveHuntDaveHunt USMember ✭✭✭✭✭

    Have you tried this on a physical device?

  • IsaacThomasIsaacThomas USMember

    Only on a simulator so far.

  • DaveHuntDaveHunt USMember ✭✭✭✭✭

    Do you have the necessary LSApplicationQueriesSchemes entries in your info.plist? See Preparing Your Apps for iOS9 for details (this also applies to iOS10).

    Also, make sure the permissions you're requesting are valid. The login flow shouldn't normally need to open the FB app, but some cases cause the flow to attempt to connect to the FB app to provide instructions to the user on resolving an issue. Without the info.plist entires mentioned above, that redirect will fail, resulting in the error you're seeing.

    That's about all I can think of.

  • FrancoisMFrancoisM FRUniversity ✭✭
    edited November 2016

    Same issue here.
    It used to work with iOS 9 so I don't think it is info.plist related. Also, it works on device with the FB app installed. Normally on the simulator or even a device, if the FB app is not there it would go through a web flow. As described by @IsaacThomas it does follow the web flow but when back to the app it crashes with the error.

    Note: I updated the Xamarin.Facebook.iOS nuget package from 4.13.1 to 4.16.1 as in the release notes they were saying: "PR 836 - pass in correct to login params for webview". However, the issue remains after the update.

    UPDATE
    Not an issue actually. The exception was in my code and not related with FB. The following message in the log is just an info that says the FB app is not installed:
    -canOpenURL: failed for URL: "fbauth2:/" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"

Sign In or Register to comment.