Last active
December 2, 2016 20:03
-
-
Save satya164/bc9e6f16f2d86a622e82ea795cc8292b to your computer and use it in GitHub Desktop.
react-native-fbsdk in React Native 0.29.+
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
Thank you, that was helpful :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.