iOS Development
Facebook SDK
iOS 10
Mobile App Development
Facebook Integration

How to use Facebook iOS SDK on iOS 10

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

Introduction

On iOS 10, Facebook SDK integration is mostly a configuration task: install the SDK, wire the app delegate, and add the required Info.plist values so the login flow can return to your app. Most failures do not come from the Swift login call itself. They come from missing URL schemes, mismatched app IDs, or incomplete app delegate forwarding.

Install the SDK

For an iOS 10 era project, CocoaPods was the common setup path.

ruby
1platform :ios, '10.0'
2use_frameworks!
3
4target 'MyApp' do
5  pod 'FacebookCore'
6  pod 'FacebookLogin'
7end

Then install the pods:

bash
pod install

After that, open the .xcworkspace file instead of the .xcodeproj. If you keep opening the project file, the Facebook frameworks will appear to be missing.

Configure Info.plist

Facebook login needs app metadata and a return URL scheme. The exact keys depend on the SDK version, but the typical setup includes:

  • 'FacebookAppID'
  • 'FacebookDisplayName'
  • a URL scheme in the form fbYOUR_APP_ID
  • app query schemes such as fbapi, fbauth2, and fb-messenger-share-api when the login flow checks for installed Facebook apps

On iOS 10, these entries matter because the platform already restricts URL queries and app-to-app transitions more tightly than very old iOS versions.

Wire the App Delegate

The Facebook SDK needs launch and URL callbacks forwarded through the app delegate.

swift
1import UIKit
2import FacebookCore
3
4@UIApplicationMain
5class AppDelegate: UIResponder, UIApplicationDelegate {
6    var window: UIWindow?
7
8    func application(
9        _ application: UIApplication,
10        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
11    ) -> Bool {
12        ApplicationDelegate.shared.application(
13            application,
14            didFinishLaunchingWithOptions: launchOptions
15        )
16        return true
17    }
18
19    func application(
20        _ app: UIApplication,
21        open url: URL,
22        options: [UIApplication.OpenURLOptionsKey: Any] = [:]
23    ) -> Bool {
24        return ApplicationDelegate.shared.application(
25            app,
26            open: url,
27            options: options
28        )
29    }
30}

If these callbacks are missing, the login flow may open but never complete correctly when control returns to the app.

Trigger Login from a View Controller

A standard login flow uses LoginManager.

swift
1import UIKit
2import FacebookLogin
3
4class ViewController: UIViewController {
5    private let loginManager = LoginManager()
6
7    @IBAction func loginTapped(_ sender: UIButton) {
8        loginManager.logIn(permissions: ["public_profile", "email"], from: self) {
9            result, error in
10
11            if let error = error {
12                print("Login failed: \(error)")
13                return
14            }
15
16            guard let result = result else {
17                print("No login result")
18                return
19            }
20
21            if result.isCancelled {
22                print("Login cancelled")
23            } else {
24                print("Login succeeded")
25            }
26        }
27    }
28}

That is the usual entry point for Facebook authentication in a UIKit app.

Fetching Basic Profile Data

After login, many apps immediately fetch profile information.

swift
1import FacebookCore
2
3let request = GraphRequest(graphPath: "me", parameters: ["fields": "id,name,email"])
4request.start { _, result, error in
5    if let error = error {
6        print("Graph request failed: \(error)")
7        return
8    }
9
10    print(result ?? "No result")
11}

This helps confirm that authentication succeeded and that the app actually received the scopes it requested.

Think in Terms of the Whole Flow

A successful iOS 10 integration depends on all of these pieces working together:

  1. SDK installed correctly
  2. Facebook developer console configured with the right bundle and app ID
  3. Info.plist values present
  4. app delegate forwarding enabled
  5. login UI calling the SDK correctly

If any one of those is missing, the login process looks broken even though the code in the button handler may be fine.

Common Pitfalls

  • Opening the .xcodeproj after running CocoaPods instead of the .xcworkspace.
  • Forgetting the fbYOUR_APP_ID URL scheme, which breaks the return path from login.
  • Missing app delegate forwarding methods for launch and open-URL events.
  • Treating an Info.plist or Facebook app-console mismatch as a Swift code bug.
  • Requesting profile fields such as email without checking whether the app has the right permissions and review state.

Summary

  • Facebook SDK integration on iOS 10 is mostly configuration plus a small amount of Swift code.
  • Install the SDK, set the required Info.plist keys, and forward app delegate callbacks.
  • Use LoginManager to start the login flow.
  • Use a Graph API request after login to confirm the session works as expected.
  • When the login fails, verify the app ID, URL scheme, and app delegate wiring before changing the Swift logic.

Related reading
Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

All Rights Reserved.