-
Notifications
You must be signed in to change notification settings - Fork 8
Setup
Sammy Isseyegh edited this page Jan 9, 2018
·
3 revisions
-
React Native CLI
$ npm install -g react-native-cli
-
RNPM
$ npm install -g rnpm
- Clone, copy, download, mirror etc.
- Update the name of your project in package.json
$ react-native upgrade
rm -r ios/RNBoilerPlate ios/RNBoiler ios/RNBoilerTests ios/build
rm ios/RNBoiler.xcodeproj
- In Xcode, right click on Libraries & add the three FBSDK frameworks to the project.
- Add the following to your info.plist, changing values in <>:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb<-facebookAppId-></string>
</array>
</dict>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
<key>FacebookAppID</key>
<string><-facebookAppId-></string>
<key>FacebookDisplayName</key>
<string><-facebookDisplayName-></string>
$ react-native bundle --entry-file ./index.ios.js --platform ios --bundle-output ios/main.jsbundle
- In Xcode --> Project --> Build Phases --> Copy Bundle Resources, ensure main.jsbundle exists, if not, add it.
- In AppDelegate.m, import the FBSDK frameworks:
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKLoginKit/FBSDKLoginKit.h>
- On line 57, return:
return [[FBSDKApplicationDelegate sharedInstance] application:application
didFinishLaunchingWithOptions:launchOptions];
- Add the following before the @end:
// Facebook SDK
- (void)applicationDidBecomeActive:(UIApplication *)application {
[FBSDKAppEvents activateApp];
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation];
}
rm -r android/build
- In android/src/main/res/values/strings.xml, ensure the project name is correct:
<resources>
<string name="app_name"><-newAppName-></string>
<string name="facebook_app_id"><-facebookAppId--></string>
</resources>
- In android/src/main/AndroidManifest.xml, ensure the 'package' property is the same as the package of the MainActivity.java file.
- In MainActivity.java:
- Ensure you have an instance variable:
CallbackManager mCallbackManager;
. - Ensure in getPackages():
- You are creating a callback:
mCallbackManager = new CallbackManager.Factory().create();
- The rnpm link has worked correctly and you have no duplicate entries in the list.
- You are creating a callback:
- Ensure you have setup an Activity Result Listener, that calls the callback's (you created above) activity result method.
public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); mCallbackManager.onActivityResult(requestCode, resultCode, data); }
- Ensure you are initialising the FacebookSdk.=
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); FacebookSdk.sdkInitialize(getApplicationContext()); }
- Ensure you have an instance variable: