-
-
Save satya164/bc9e6f16f2d86a622e82ea795cc8292b to your computer and use it in GitHub Desktop.
public class MainActivity extends ReactActivity { | |
/** | |
* Returns the name of the main component registered from JavaScript. | |
* This is used to schedule rendering of the component. | |
*/ | |
@Override | |
protected String getMainComponentName() { | |
return "MyApp"; | |
} | |
@Override | |
public void onActivityResult(int requestCode, int resultCode, Intent data) { | |
MainApplication.getCallbackManager().onActivityResult(requestCode, resultCode, data); | |
} | |
} |
public class MainApplication extends Application implements ReactApplication { | |
private static CallbackManager mCallbackManager = new CallbackManager.Factory().create(); | |
@Override | |
public void onCreate() { | |
FacebookSdk.sdkInitialize(this); | |
} | |
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { | |
@Override | |
protected boolean getUseDeveloperSupport() { | |
return BuildConfig.DEBUG; | |
} | |
@Override | |
protected List<ReactPackage> getPackages() { | |
return Arrays.<ReactPackage>asList( | |
new MainReactPackage(), | |
new FBSDKPackage(mCallbackManager), | |
); | |
} | |
}; | |
@Override | |
public ReactNativeHost getReactNativeHost() { | |
return mReactNativeHost; | |
} | |
protected static CallbackManager getCallbackManager() { | |
return mCallbackManager; | |
} | |
} |
@mehdichamouma I think we don't need to. React Native doesn't do that internally either.
@satya164 Turns out you absolutely need to. I lost a whole day because of this.
I'm using the react-native-google-signin
package, they are firing a startActivityForResult
.
If the call to super
is omitted here, the onActivityResult
on their side is never called and Google signin doesn't work.
I'm no sure why this happens, my Java is a little rusty, I'd definitely be interested in an explanation, if anyone can provide any :p
Anyway, the react-native-fbsdk
docs are up to date now, hopefully no one else will stumble on this.
Thanks for this gist, everything works fine but FBSDKPackage cannot be found. Is there any way to import that package? Thanks.
Figured it out! It was my mistake. I tried to import MainReactPackage twice.
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new ReactNativePushNotificationPackage(),
new MainReactPackage(),
new FBSDKPackage(mCallbackManager)
);
Just gonna leave it here for anyone who runs into the same mistake.
Thank you, that was helpful :)
Thanks, works like a charm!
@mehdichamouma, @SudoPlz something like this?