Skip to content

Instantly share code, notes, and snippets.

@satya164
Last active December 2, 2016 20:03
Show Gist options
  • Save satya164/bc9e6f16f2d86a622e82ea795cc8292b to your computer and use it in GitHub Desktop.
Save satya164/bc9e6f16f2d86a622e82ea795cc8292b to your computer and use it in GitHub Desktop.
react-native-fbsdk in React Native 0.29.+
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;
}
}
@thevishnupradeep
Copy link

thevishnupradeep commented Oct 16, 2016

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.

@tetherit
Copy link

tetherit commented Dec 2, 2016

Thank you, that was helpful :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment