facebookarchive / react-native-fbsdk

A React Native wrapper around the Facebook SDKs for Android and iOS. Provides access to Facebook login, sharing, graph requests, app events etc.
https://developers.facebook.com/docs/react-native
Other
2.99k stars 907 forks source link

logInWithPermissions Promise not being resolved #608

Closed eran-pinhas closed 5 years ago

eran-pinhas commented 5 years ago

Hi,

In android - the promise returned from the logInWithPermissions function seems to be ok but it's not resolved (nor rejected...) after successful login. same issue when using the <LoginButton /> callbacks are not being called back.

What am I missing? anyone seen that behavior before?

  try {
    const result = await LoginManager.logInWithPermissions(["public_profile", "email", "user_friends"]);
    console.log(result);
  } catch (err) {
    console.log(err);
  }

FYI: it seems that this package is not well supported. Issues are not being closed (~20% open issues) and not all functions are documented. I really think facebook can do a tiny bit better

Thanks y'all

Subiyel commented 5 years ago

Same issue, any ideas

dsgithub2018 commented 5 years ago

Hi, I am not able to setup react-native-fbsdk in IOS whereas it is working fine in ANDROID. I am using react-native 0.60.4 and in my package.json I have mentioned, "react-native-fbsdk": "git+https://github.com/facebook/react-native-fbsdk.git" and my pod file is like,

pod 'FBSDKCoreKit', '~> 5.0'

pod 'FBSDKLoginKit', '~> 5.0'

pod 'FBSDKShareKit', '~> 5.0'

But I am always getting the below error after each successful build in IOS, TypeError: Cannot read property 'logInWithPermissions' of undefined

I am using LoginManager.logInWithPermissions(["public_profile", "email"]) in my code. I am not able to fix this issue from NEW REACT-NATIVE 0.60.0, now the latest version is 0.60.4, but still the same issue! Please help me to fix this issue.

aanah0 commented 5 years ago

same issue

aanah0 commented 5 years ago

I resolve issue for me.

check is implement this method in your MainActivity


    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        MainApplication.getCallbackManager().onActivityResult(requestCode, resultCode, data);
    }
smooJitter commented 5 years ago

@aanah0 where did you download the FB SDK 5.0 from

dsgithub2018 commented 5 years ago

I resolve issue for me.

check is implement this method in your MainActivity

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        MainApplication.getCallbackManager().onActivityResult(requestCode, resultCode, data);
    }

My issue is in IOS, not in Android. Would you please give any idea for IOS?

Subiyel commented 5 years ago

i also had same issue with IOS, resolved it by downgrading version to: pod 'FBSDKCoreKit', ~> 4.40.0' pod 'FBSDKLoginKit', ~> 4.40.0' pod 'FBSDKShareKit', ~> 4.40.0' and using logInWithReadPermissions

i am using RN 58.4

dsgithub2018 commented 5 years ago

I have found the following line in react-native-fbsdk(latest)->js->FBLoginManager.js, const LoginManager = require('react-native').NativeModules.FBLoginManager;

But when I console the require('react-native'), I saw there is no FBLoginManager in NativeModules. I think that's why I am always getting the error like, LoginManager undefined. But FBLoginManager is available when I console the same in Android! Can anybody fix this issue?

dsgithub2018 commented 5 years ago

Any fix?

dsgithub2018 commented 5 years ago

I have found the following line in react-native-fbsdk(latest)->js->FBLoginManager.js, const LoginManager = require('react-native').NativeModules.FBLoginManager;

But when I console the require('react-native'), I saw there is no FBLoginManager in NativeModules. I think that's why I am always getting the error like, LoginManager undefined. Can anybody fix this issue?

Where is the exact issue then? The issue is in react-native or react-native-fbsdk? The same thing is working fine in Android! Actually I am not sure if anything wrong in my end, so can anybody give me the steps to integrate a successful facebook login in react-native(in IOS only)?

gidox commented 5 years ago

i have the same issue on android

vivekkadu commented 5 years ago

any solution ?? i am facing same issue ..

ponchautf commented 5 years ago

I got the same issue on Android but it's working fine on iOS. and my main activity implement the onActivityResult (solution proposed by dsgithub2018 does not help)

gidox commented 5 years ago

i resolved this with onActivityResult solution + adding "implementation 'com.facebook.android:facebook-login:[5,6)'" in build.gradlew (dependencies

kentrh commented 5 years ago

I solved it by upgrading from v0.10.1 to v1.0.1. Remember to remove all the CallbackManager stuff in MainApplication.java

janicduplessis commented 5 years ago

We have a fix for some callbacks not getting called on android in v1.0.2, also like mentionned previously make sure to remove all CallbackManager stuff.

cchamikara commented 5 years ago

I'm not using cocopod but still has this issue

kentrh commented 5 years ago

@cchamikara I wasn't using Cocoapods either, but it still fixed it. FBSDK's at version 5.3.0.

cchamikara commented 5 years ago

@kentrh I did remove frameworks and download them from https://github.com/facebook/facebook-objc-sdk/releases/tag/v5.3.0 and dragged them to frameworks again and tried but still same issue , Am I doing correct thing ?

kentrh commented 5 years ago

@cchamikara I guess there's quite some config to be done when not using CocoaPods, so you should follow the instructions at https://github.com/facebook/react-native-fbsdk. Make sure you put your SDK's in ~/Documents/FacebookSDK and that you upgrade the package with yarn upgrade react-native-fbsdk --latest But isn't this really an Android issue? For me it was always working on iOS, but the promise was never returned on Android.

cchamikara commented 5 years ago

@kentrh yes I did follow all the steps , it is working on Android but not in iOS

jsmile1994 commented 5 years ago

@cchamikara Did you find the solution for this issue? It works well on Android but with iOS, it built fail with this one: "Initializing 'FBSDKLoginManagerLoginResult __strong' with an expression of incompatible type 'void (^)(FBSDKLoginManagerLoginResult strong, NSError *strong)'"