react-native-facebook-login
react-native-facebook-login copied to clipboard
Click on button crashes the app
Hello,
I tried to setup the component in my application and followed the steps for iOS. It turned out, the click on the Facebook login button crashes the application.
I tried the same thing with a new application from scratch and the same behaviour happened, I definitly have no idea what I did wrong. I did not try for Android yet.
Here is the application from sratch with the component installed for iOS :
https://github.com/CitizenFiftyTwo/reactFirebase
Cheers.
This shit does not even work. It is badly documented and nobody is here to help. I don't even know the purpose of this component.
Well thanks pricks.
Still having this issue?
Do you have the (official) facebook app installed?
I think I have the same problem if it's not installed. If it's the same thing, you might be able to go around it by either installing facebook or trying different loginBehavior props to your FBLogin.
For example:
<FBLogin loginBehavior={FBLoginManager.LoginBehaviors.Web} />
Hope it helps.
Edit: the possible values are: "Native", "Browser", "SystemAccount" and "Web"
I have the same problem. Changing the loginBehavior to Web did not help :(
@dsog @kklaine
As long as you followed the directions in the readme + have the following properties in your Info.plist configured for your iOS project, it should work. Also, check your debug log (Simulator > Debug > Open System Log...) for reasons why it may be crashing.
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb{your-app-id}</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>{your-app-id}</string>
<key>FacebookDisplayName</key>
<string>{your-app-name}</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
I may be hitting the same problem. and changing the loginBehavior to Web, above advice from @brh55 is not working for me.
So here is the log when FBLogin is clicked... Any advices are very appreciate. (Changing loginBehavior from Web to Browser is showing another exception thought)
React-Native: 0.44.2 Xcode 8.3.3 iOS Deployment target 9.0 Run on iPhone 5s emulator
2017-07-22 07:17:29.857 RN[18193:1037582] -[__NSCFString containsObject:]: unrecognized selector sent to instance 0x600000042850 2017-07-22 07:17:29.876 RN[18193:1037582] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString containsObject:]: unrecognized selector sent to instance 0x600000042850' *** First throw call stack: ( 0 CoreFoundation 0x000000010a20fb0b __exceptionPreprocess + 171 1 libobjc.A.dylib 0x00000001090c5141 objc_exception_throw + 48 2 CoreFoundation 0x000000010a27f134 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132 3 CoreFoundation 0x000000010a196840 forwarding + 1024 4 CoreFoundation 0x000000010a1963b8 _CF_forwarding_prep_0 + 120 5 RN 0x0000000108747e67 +[FBSDKInternalUtility isRegisteredURLScheme:] + 284 6 RN 0x0000000108747bd1 +[FBSDKInternalUtility validateURLSchemes] + 184 7 RN 0x00000001086fd0cc -[FBSDKLoginManager logInParametersWithPermissions:] + 82 8 RN 0x00000001086fd5b9 -[FBSDKLoginManager logInWithBehavior:] + 50 9 RN 0x00000001086fd571 -[FBSDKLoginManager logInWithPermissions:handler:] + 238 10 RN 0x00000001086fc28f -[FBSDKLoginManager logInWithReadPermissions:fromViewController:handler:] + 257 11 RN 0x00000001086f8d5b -[FBSDKLoginButton _buttonPressed:] + 1082 12 UIKit 0x000000010c45fd82 -[UIApplication sendAction:to:from:forEvent:] + 83 13 UIKit 0x000000010c5e45ac -[UIControl sendAction:to:forEvent:] + 67 14 UIKit 0x000000010c5e48c7 -[UIControl _sendActionsForEvents:withEvent:] + 450 15 UIKit 0x000000010c5e3802 -[UIControl touchesEnded:withEvent:] + 618 16 UIKit 0x000000010c4cd7ea -[UIWindow _sendTouchesForEvent:] + 2707 17 UIKit 0x000000010c4cef00 -[UIWindow sendEvent:] + 4114 18 UIKit 0x000000010c47ba84 -[UIApplication sendEvent:] + 352 19 UIKit 0x000000010cc5f5d4 __dispatchPreprocessedEventFromEventQueue + 2926 20 UIKit 0x000000010cc57532 __handleEventQueue + 1122 21 CoreFoundation 0x000000010a1b5c01 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17 22 CoreFoundation 0x000000010a19b0cf __CFRunLoopDoSources0 + 527 23 CoreFoundation 0x000000010a19a5ff __CFRunLoopRun + 911 24 CoreFoundation 0x000000010a19a016 CFRunLoopRunSpecific + 406 25 GraphicsServices 0x0000000110078a24 GSEventRunModal + 62 26 UIKit 0x000000010c45e134 UIApplicationMain + 159 27 RN 0x00000001085b8abf main + 111 28 libdyld.dylib 0x000000010de4265d start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)
I had the same issue, updating Info.plist like @brh55 suggested above and then rebuilding solved the issue for me.
I believe the instructions in the readme might be incomplete?
FBSDK now provides a login button, I would look into that if you are having troubles with this
Thanks @brh55 and @kklaine!! Very poor documentation in this library :(
Provide the following in your info.plist
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb[APP_ID]</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>[APP_ID]</string>
<key>FacebookDisplayName</key>
<string>[APP_NAME]</string>
Following works for me:
const FBLoginManager = NativeModules.MFBLoginManager;
...
async componentDidMount() {
const fbView = Platform.OS === 'ios'
? FBLoginManager.LoginBehaviors.Web
: FBLoginManager.LoginBehaviors.WebView;
await FBLoginManager.setLoginBehavior(fbView);
}
But it is still not the best solution, as it does not trigger the native Facebook app, when it is installed. So with this solution, users always have to write their credentials.
For android just run "adb logcat" to see all logs and most important - stack trace. My issue was related to permissions: "Cannot pass a read permission (email) to a request for publish authorization" I changed "publishPermissions" to "readPermissions" on the fb login js script, and it worked. (got this solution from other StackOverflow page)
@hayduas answer helped me to have it working on Android but iOS was still crashing.
In order to have it working on iOS I had to:
- Update the Info.plist xml (Open as Source Code):
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>fb<APP_ID></string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string><APP_ID></string>
<key>FacebookDisplayName</key>
<string><APP_NAME></string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
<string>fb<APP_ID></string>
</array>
- I had to change in Info.plist (Open as Property list) the value of URL types > Item 0 (Editor) > URL Schemes > Item 0 and set it to
fb<APP_ID>.
I found the solution on stack overflow