0% found this document useful (0 votes)
28 views5 pages

Quick Start For iOS

The document provides instructions for adding the Facebook SDK to an iOS project to enable Facebook login and sharing. It includes steps to download and configure the SDK, add login and sharing buttons, and test the integration.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views5 pages

Quick Start For iOS

The document provides instructions for adding the Facebook SDK to an iOS project to enable Facebook login and sharing. It includes steps to download and configure the SDK, add login and sharing buttons, and test the integration.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Quick Start for iOS

Download and install the Facebook SDK for iOS


Download the SDK and unzip the file to ~/Documents/FacebookSDK

Download SDK

Add the Facebook SDK to your Xcode Project

From the Facebook SDK folder, drag the Bolts.framework, FBSDKCoreKit.Framework,


FBSDKLoginKit.Framework, FBSDKShareKit.Framework folder to your Xcode Projects
Framework folder.

Open the "Build Settings" tab of Xcode in your project and add the Facebook SDK folder
path to the "Framework Search Paths" configuration.

Configure your project settings and info.plist


Find the .plist file in the Supporting Files folder in your Xcode Project.

1. Right-click on your .plist file and choose "Open as source".

2. Copy and paste the XML snippet into the body of your file (<dict>... </dict>).

<key>CFBundleURLTypes</key>

<array>

<dict>

<key>CFBundleURLSchemes</key>

<array>

<string>fb708764581454905</string>

</array>

</dict>

</array>

<key>FacebookAppID</key>
<string>708764581454905</string>

<key>FacebookDisplayName</key>

<string>FYTme</string>

3. If you use any Facebook dialogs (e.g., Login, Share, App Invitations, etc.) that might
perform an app switch to Facebook apps, your app's .plist will need to consider that as
well.

<key>LSApplicationQueriesSchemes</key>

<array>

<string>fbapi</string>

<string>fb-messenger-api</string>

<string>fbauth2</string>

<string>fbshareextension</string>

</array>

4. Add a compiler flag to your build settings for compatibility with the Facebook SDK for
iOS.

1. Go to Project Navigator in Xcode and select your project to see the project
settings.

2. Select Other Connection Builder Flags to edit.

3. Add the -ObjC flag to the Other Connection Builder flags for all build targets.

Enter your package identifier


Locate your package identifier in the destination of the Project Xcode iOS app

Package Identifier
com.example.fytme

Track app installs and opens


App Events allow you to measure installs on your mobile app's ads, create high-value
audiences to target, and view analytics including user demographics. To log an app
activation event, first import the Facebook SDK into your AppDelegate.m file:

#import <FBSDKCoreKit/FBSDKCoreKit.h>

Then, add the following to your Delegate app:

- (void)applicationDidBecomeActive:(UIApplication *)application {

[FBSDKAppEvents activateApp];

- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

[[FBSDKApplicationDelegate sharedInstance] application:application

didFinishLaunchingWithOptions:launchOptions];

return YES;

- (BOOL)application:(UIApplication *)application

openURL:(NSURL *)url

sourceApplication:(NSString *)sourceApplication

annotation:(id)annotation {

return [[FBSDKApplicationDelegate sharedInstance]


application:application

openURL:url

sourceApplication:sourceApplication
annotation:annotation];

When people install or engage with your app, you'll see that data reflected in your
app's Insights dashboard.

Does your app support in-app purchases?


Log in-app purchase events automatically on iOS (recommended)
When you enable this option, all in-app purchase events will be logged automatically. This feature
YES requires Facebook SDK for iOS version 3.22 or later.
NO Notice: When this setting is enabled, you must stop registering in-app purchases manually or they
will be duplicated. Learn more

Let's test your integration


In one of your app's ViewController.m files, add:

#import <FBSDKLoginKit/FBSDKLoginKit.h>

Next, add the following code to the viewDidLoad method:

FBSDKLoginButton *loginButton = [[FBSDKLoginButton alloc] init];

loginButton.center = self.view.center;

[self.view addSubview:loginButton];

If you haven't already done so, add the following to your app's AppDelegate.m file:

#import <FBSDKCoreKit/FBSDKCoreKit.h>

- (BOOL)application:(UIApplication *)application

openURL:(NSURL *)url

sourceApplication:(NSString *)sourceApplication

annotation:(id)annotation {

return [[FBSDKApplicationDelegate sharedInstance]


application:application
openURL:url

sourceApplication:sourceApplication

annotation:annotation];

Now build and run your application. You should see a Facebook Sign In button. If you're
able to sign in to your app, the integration was successful.

Next steps
Congratulations! You've added the Facebook SDK to your project. Now you're at the next
step of integrating your app with Facebook. What do you want to do next? Skip to
Developer Dashboard or Documentation

Share Login Ads Monetize


Add the sharing dialog to Add Facebook Login to let Grow your app Monetize your
allow people to share your people know how quick and with Facebook Ads mobile app with
content with their friends. easy it is to log in to your app. for Apps Facebook Ads

You might also like