magus / react-native-facebook-login

React Native component wrapping the native Facebook SDK login button and manager
MIT License
1.24k stars 327 forks source link

Unable to get callback working in Simulator #187

Open sathyakumarseshachalam opened 7 years ago

sathyakumarseshachalam commented 7 years ago

I followed the steps outlined, And got FBLogin working. But since am running on iOS simulator, the behaviour I am seeing is that the onLoginFound callback is never called and safari browser window just shows a blank facebook page after facebook authorization.

My code snippet is this

<FBLogin style={{ marginBottom: 10, }}
                     permissions={["email","public_profile"]}
                     loginBehavior={FBLoginManager.LoginBehaviors.Native}
                     onLogin={function(data){
                       console.log("Logged in!");
                       console.log(data);
                     }}
                     onLogout={function(){
                       console.log("Logged out.");
                     }}
                     onLoginFound={function(data){
                       console.log("Existing login found.");
                       console.log(data);
                     }}
                     onLoginNotFound={function(){
                       console.log("No user logged in.");
                     }}
                     onError={function(data){
                       console.log("ERROR");
                       console.log(data);
                     }}
                     onCancel={function(){
                       console.log("User cancelled.");
                     }}
                     onPermissionsMissing={function(data){
                       console.log("Check permissions!");
                       console.log(data);
                     }}
            />

And the screenshot of simulator post FB autorization below. Clicking 'Done' there does not result in any callbacks. On RN ^0.35.0 simulator screen shot 26-nov-2016 6 00 21 pm

laibulle commented 7 years ago

I have the same behavior

sathyakumarseshachalam commented 7 years ago

My lack of Swift knowledege or iOS is hurting here. But here is a link that explains the problem. Not sure what to make of it though.

forum link

garrettmac commented 7 years ago

+1

garrettmac commented 7 years ago

Im not sure what did if but i fixed this issue by replacing my "[project name].xcodeproj > [project name] > AppDelegate.m" with the examples https://github.com/magus/react-native-facebook-login/blob/master/example/ios/example/AppDelegate.m then changed the moduleName:@"[YOUR FB APP NAME]"

then made sure I allowed "http://localhost:8081" and "http://localhost:8081/auth/facebook/callback" under "Valid OAuth redirect URIs" at https://developers.facebook.com/apps/[app id]/fb-login/

joaofranca commented 7 years ago

Same problem, did what is described above by @garrettmac, however the problem was being caused by the following code in the app delegate:

- (BOOL)application:(UIApplication *)app
            openURL:(NSURL *)url
            options:(NSDictionary *)options {
  return [[GIDSignIn sharedInstance] handleURL:url
                             sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
                                    annotation:options[UIApplicationOpenURLOptionsAnnotationKey]];
}

Instead, remove the above and only use

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
  return [[FBSDKApplicationDelegate sharedInstance] application:application
                                                        openURL:url
                                              sourceApplication:sourceApplication
                                                     annotation:annotation] || [RNGoogleSignin application:application
                                                                                                   openURL:url
                                                                                         sourceApplication:sourceApplication
                                                                                                annotation:annotation
                                                                                ];

Note that I also have google auth in my project, thus the conflict.