在Facebook Messenger中的UIActivityViewController中发送图像+网址

Nic*_*nto 22 facebook ios uiactivityviewcontroller facebook-messenger

使用简单的UIActivityViewController

-(void)share{

    NSString *textToShare = _mytext;
NSURL *url = [NSURL URLWithString:@"http://www.google.com"];
    UIImage *imageToShare = _myimage;
    NSArray *activityItems = @[textToShare, url,  imageToShare];
    UIActivityViewController *activityVC =
    [[UIActivityViewController alloc] initWithActivityItems:activityItems
                                      applicationActivities:nil];

    [self presentViewController:activityVC animated:YES completion:nil];
}
Run Code Online (Sandbox Code Playgroud)

我想在适当的时候分享文字,网址和图片.

因此,如果用户选择邮件,则会显示所有内容.与其他应用程序等(pinterest,facebook,twitter)

在Facebook Messenger上 - 如果共享了网址和图像,则共享屏幕崩溃.这是一个已知问题(无法使用网址发送图片)?

Вик*_*нов 1

* 编辑:更新到最新的SDK

FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.contentTitle = @"Your title";
content.contentDescription = @"Some description text maybe...";
content.contentURL = [NSURL URLWithString:@"http://yourlink.com"];
content.imageURL = [NSURL URLWithString:@"http://yourlink.com/theImage.png"];

[FBSDKMessageDialog showWithContent:content delegate:self];


// Delegate
- (void)sharer: (id<FBSDKSharing>)sharer didCompleteWithResults: (NSDictionary *)results 
{
    BOOL complete = [[results valueForKeyPath:@"didComplete"] boolValue];
    NSString *completionGesture = [results valueForKeyPath:@"completionGesture"];
    if (completionGesture && [completionGesture isEqualToString:@"cancel"]) {
        // action was canceled by the user
    }

    if (complete) {
        // the message/link/image was sent
    }
}

- (void) sharer:(id<FBSDKSharing>)sharer didFailWithError:(NSError *)error
{
    // handle error...
}
Run Code Online (Sandbox Code Playgroud)

你可以尝试一下:)

  • 那是 facebook,不是 Messenger,也不在 uiactivitycontroller 中 (18认同)
  • 这不是 UIActivityViewController。 (3认同)