iOS Facebook SDK MessageDialog error 202

前端 未结 4 829
余生分开走
余生分开走 2021-02-06 02:43

I am trying to set up Facebook sharing with FBSDK in my iOS app.

I have been reading the documentation here, and currently have

[FBSDKShareDialog showF         


        
4条回答
  •  -上瘾入骨i
    2021-02-06 03:21

    I had to login and then Post , that is how it worked :

    FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
    
    
    [login logInWithReadPermissions:@[@"email"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error)
    {
    
        if (error)
        {
        // Process error
        }
        else if (result.isCancelled)
        {
            // Handle cancellations
        }
        else
        {
            FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
            content.contentURL = [NSURL URLWithString:@"https://developers.facebook.com/"];
    
            FBSDKMessageDialog *messageDialog = [[FBSDKMessageDialog alloc] init];
            messageDialog.delegate = self;
            [messageDialog setShareContent:content];
    
            if ([messageDialog canShow])
            {
                [messageDialog show];
            }
            else
            {
                // Messenger isn't installed. Redirect the person to the App Store.
                [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://itunes.apple.com/en/app/facebook-messenger/id454638411?mt=8"]];
            }
    
        }
    }];
    

    and the Share Delegate :

    - (void)sharer:(id)sharer didCompleteWithResults:(NSDictionary *)results
    {
        NSLog(@"didCompleteWithResults");
    }
    
    - (void)sharer:(id)sharer didFailWithError:(NSError *)error
    {
        NSLog(@"didFailWithError ::: %@" , error);
    }
    
    - (void)sharerDidCancel:(id)sharer
    {
        NSLog(@"sharerDidCancel");
    }
    

    Edit:

    [messageDialog canShow] returns NO on the iPad, works fine on iPhone

    Posted the issue on Facebook Developers forum.

提交回复
热议问题