Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure Facebook for Android #9

Merged
merged 1 commit into from Dec 5, 2016
Merged

Configure Facebook for Android #9

merged 1 commit into from Dec 5, 2016

Conversation

jpgarcia
Copy link
Contributor

@jpgarcia jpgarcia commented Nov 23, 2016

Summary

Configure react-native-fbsdk library to work on Android devices

Configure android project files

  1. Open android/app/src/main/res/values/strings.xml and provide the Facebook application id:

    <string name="facebook_app_id">1788844961356591</string>
  2. Open android/app/src/main/AndroidManifest.xml and add the following line inside the application node:

    <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
  3. Open android/app/src/main/java/com/platzimusic/MainApplication.java:

    • Add the following imports:
      import com.facebook.CallbackManager;
      import com.facebook.FacebookSdk;
      import com.facebook.reactnative.androidsdk.FBSDKPackage;
      import com.facebook.appevents.AppEventsLogger;
    • Add an instance variable of type CallbackManager and its getter:
      private static CallbackManager mCallbackManager = CallbackManager.Factory.create();
      
      protected static CallbackManager getCallbackManager() {
        return mCallbackManager;
      }
    • Register sdk package in method getPackages():
      return Arrays.<ReactPackage>asList(
        new MainReactPackage(),
        new FBSDKPackage(mCallbackManager)
      );
    • Override onCreate() method
      @Override
      public void onCreate() {
        super.onCreate();
        FacebookSdk.sdkInitialize(getApplicationContext());
        AppEventsLogger.activateApp(this);
      }
  4. Open android/app/src/main/java/com/platzimusic/MainActivity.java:

    • Add the following import:
      import android.content.Intent;
    • Inside the MainActivity class:
      @Override
          public void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);
          MainApplication.getCallbackManager().onActivityResult(requestCode, resultCode, data);
      }    

@gaguirre gaguirre merged commit 86f3871 into auth Dec 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants