FBSDKSharing Callback not returning results

前端 未结 3 1873
春和景丽
春和景丽 2021-01-27 17:15

In my iOS app, I have a Facebook share button, which opens up a FBSDKShareDialog:

-(IBAction)post:(id)sender{

    FBSDKShareLinkContent *content = [[FBSDKShareL         


        
3条回答
  •  清酒与你
    2021-01-27 17:47

    The solution is to check in the delegate method sharer:didCompleteWithResults: if user has Facebook installed as @Adam Eisfeld suggested :

    - (void)sharer:(id)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.

提交回复
热议问题