FBSDKSharing Callback not returning results

前端 未结 3 1874
春和景丽
春和景丽 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<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.

    0 讨论(0)
  • 2021-01-27 18:03

    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.

    0 讨论(0)
  • 2021-01-27 18:11

    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
    
    0 讨论(0)
提交回复
热议问题