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.
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.
Then install the pods:
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, andfb-messenger-share-apiwhen 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.
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.
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.
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:
- SDK installed correctly
- Facebook developer console configured with the right bundle and app ID
- Info.plist values present
- app delegate forwarding enabled
- 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
.xcodeprojafter running CocoaPods instead of the.xcworkspace. - Forgetting the
fbYOUR_APP_IDURL 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
LoginManagerto 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
- How to use generic protocol as a variable type
- How to use Git properly with Xcode?
- How to use icons and symbols from Font Awesome on Native Android Application
- How to use LocalBroadcastManager?
- How to use Namespaces in Swift?
- How to use Namespaces in Swift?
- How to use NSCache
- How to use NSJSONSerialization
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack 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.