Our Blog

Drupal to iOS/Android Conversion Series: Facebook SDK

Continuing with our posts, on our WordPress/Drupal to mobile app conversion software, here is a more technical post explaining how we integrated the Facebook SDK into our wrapper technology tallow native single sign on from your app homescreen.

The steps are as follows.
1. Download SDK
2. Create Facebook App
3. App Settings
4. Add SDK
5. Configure Xcode
6. Connect Application Delegate
7. Add App Events

1) Download the SDK and unzip the archive to ~/Documents/FacebookSDK.

2) If your app is not yet registered with Facebook and has an app ID, you should create it. You can share an app ID across platforms from this link :- https://developers.facebook.com/?advanced_app_create=true

3) 1. Select Settings in App Dashboard.

  1. Click Add Platform and choose iOS.
    2. Then provide your Bundle Identifier in the Bundle ID field.
    3. Enable Single Sign On.
    4. Click Save Changes

4) To add the SDK in Xcode:

  1. Open ~/Documents/FacebookSDK
    2. Drag the FBSDKCoreKit.framework to Frameworks in Project Navigator. Create a new group Frameworks if it does not exist.
    3. Choose Create groups for any added folders.
    4. Deselect Copy items into destination group’s folder. This references the SDK where you installed it rather than copying the SDK into your app.

The SDK automatically loads its framework and resource dependencies.

5) Now configure the .plist for your project:

  1. In Xcode right-click your .plist file and choose “Open As Source Code”.
    2. Copy & Paste the XML snippet into the body of your file (<dict>…</dict>).
    3. Replace:

fb{your-app-id} with your Facebook App ID and the prefix fb. E.g.: fb123456.
{your-app-id} with your Facebook App ID.
{your-app-name} with the Display Name you configured in the app dashboard.


6) To post process the results from Facebook Login or Facebook Dialogs (or any action that requires switching over to the native Facebook app or Safari) you need to connect your AppDelegate to theFBSDKApplicationDelegate. In your AppDelegate.m add:

– (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
   return [[FBSDKApplicationDelegate sharedInstance] application:application

7) Add App Events

The SDK is installed and set up. The easiest way to test your implementation is to add App Events to your app. App Events help you understand the makeup of people who engage with your app. This is done by logging events via one of 14 predefined events such as ‘added to cart’ in a commerce app or ‘level achieved’ in a game, or any custom events you can define.
Log App Activations
A basic example is to log app activations. To do so add the following code snippet to yourAppDelegate.m:

– (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

   [FBSDKAppEvents activateApp];

After that while clicking on some button add this code :—


FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
   [login logInWithReadPermissions:@[@”email”] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
       if (error) {
           // Process error
       } else if (result.isCancelled) {
           // Handle cancellations
       } else {
           // If you ask for multiple permissions at once, you
           // should check if specific permissions missing
           if ([result.grantedPermissions containsObject:@”email”]) {
               // Do work
               } else
                   NSLog(@”Not granted”);
               NSLog(@”Response:: %@”, result.grantedPermissions);
               [FBSDKProfile enableUpdatesOnAccessTokenChange:YES];

Congratulations Facebook integration is now complete!. You can create API’s and add your own logic for FB integration in any app.