You can use one Facebook app ID in multiple iOS apps, for example, between free and paid versions of your app.
Define a URL scheme suffix parameter,
FacebookUrlSchemeSuffix, in your app's
Note: Suffix only works with alpha characters.
Since the native share dialog is part of Facebook's iOS app, it can't run on a simulator. Use a physical device to test the native share dialog. We're looking at ways to make it possible to test the native share dialog in the simulator.
Make sure you have the correct import statements at the top of each file where you're trying to use the Facebook SDK classes. For example:
#import <FBSDKCoreKit/FBSDKCoreKit.h> #import <FBSDKShareKit/FBSDKShareKit.h> #import <FBSDKLoginKit/FBSDKLoginKit.h>
When using frameworks in Objective-C, classes that use categories to extend existing classes are not loaded automatically.
When you try to call a method that has been extended in these classes, you will get an
unrecognized selector sent to instance error. Classes that are used from the Xcode interface builder are also not loaded automatically, for example when you add a
FBSDKLoginButton to your interface by drawing a view in your .xib file and then setting it as
FBSDKLoginButton from the interface builder UI. So again, when you try to call methods on them, you will get an
unrecognized selector sent to instance error. To solve this problem you have two options.
You can load the class manually in your app delegate's
application:didFinishLaunchingWithOptions:, by calling:
Or you can add the
-ObjC linker flag. This flag tells the linker to load every object file in the SDK that defines an Objective-C class or category. This approach will make all our classes work out of the box but it will increase the size of your executable (due to additional object code loaded into the application).
To add the
-ObjC flag, click on the project target and select the "Build Settings" tab. There, under "Linking", double-click "Other Linker Flags" to add
It's common to have configuration errors in the
.plist. Make sure that the
.plist includes rows for
FacebookDisplayName and URL Type entry for
If you're getting unexpected results when making Graph API requests, enable the debug mode by adding this code before any requests:
[FBSettings setLoggingBehavior: [NSSet setWithObject:FBSDKLoggingBehaviorGraphAPIDebugInfo]];
FBSDKLoggingBehaviorGraphAPIDebugWarning if you would like to suppress info level messages and keep only warnings.
Enabling this logging behavior will add
debug param to all Graph API requests and output any occurring issues in console.
You can read more about Graph API Debug Mode here.
The SDK will report a cancellation if the user explicitly taps a cancel button in the login dialogs, or if they manually app switch back to your app (known as an implicit cancellation). You should make sure you are not initiating a login flow as part of your app delegate's lifecycle (such as starting a login inside
application:openURL:sourceApplication:annotation:) as that will mimic an implicit cancellation. If you must, dispatch the login initiation later to the main queue so that the app delegate's lifecycle completes first.
The Share dialog notifies its delegate's
sharerDidCancel: methods upon a user action.
sharer:didCompleteWithResults: when the user successfully shares. If that user has not logged in with Facebook Login, this method will also be called if the user clicks on
sharerDidCancel: when someone clicks Share dialog's
X button; or if they have logged in with Facebook Login and click on
If you're getting unexpected results when making requests, turn on debugging for
FBSDKGraphRequests. Add this code before any requests:
You'll be able to debug any issues by viewing requests and responses from the servers directly.
Consider looking at the other
FBSDKLoggingBehavior* constants defined in
FBSDKSettings.h for other things you can log.