In my iOS app, I have a Facebook share button, which opens up a FBSDKShareDialog:
-(IBAction)post:(id)sender{
FBSDKShareLinkContent *content = [[FBSDKShareL
The solution is to check in the delegate method sharer:didCompleteWithResults:
if user has Facebook installed as @Adam Eisfeld suggested :
- (void)sharer:(id<FBSDKSharing>)sharer didCompleteWithResults:(NSDictionary *)results{
// check if user has facebook app installed
NSURL *fbURL = [NSURL URLWithString:@"fb://"];
// there is no facebook app installed
if (![[UIApplication sharedApplication] canOpenURL:fbURL]){
// facebook is not intalled check the keys
if (results.allKeys.count !=0){
// success you can get your post ID
}else {
// if resutlst.allKeys == 0 means user press Done button
}
} else {
// the share is successfully and facebook is installed
}
}
and from iOS9.0 do not forget to add in your .plist file LSApplicationQueriesSchemes
key (an array of strings) and add fb
check this post for more details.
According to the documentation, result
may be nil or empty. There is no guarantee that you will actually get something back that could be used by your app to confirm a share/post has been made.
Looks FB changed something on Delegate it when user share the delegate method will run with empty results, so if you are check something in this method to make sure that post posted correctly just remove it
- (void)sharer:(id<FBSDKSharing>)sharer didCompleteWithResults:(NSDictionary *)results
and when user cancel share this method will run
- (void)sharerDidCancel:(id<FBSDKSharing>)sharer