将视频分享到facebook Messenger

时间:2015-08-12 15:02:42

标签: ios objective-c facebook

我正在尝试使用代码

通过facebook messenger分享视频
        ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
        [library writeVideoAtPathToSavedPhotosAlbum:videoUrl completionBlock:^(NSURL *assetURL, NSError *error) {

            FBSDKShareVideo *video = [FBSDKShareVideo new];
            video.videoURL = assetURL;
            FBSDKShareVideoContent *content = [[FBSDKShareVideoContent alloc] init];
            content.video = video;

            FBSDKMessageDialog *messageDialog = [[FBSDKMessageDialog alloc] init];
            messageDialog.delegate = self;
            [messageDialog setShareContent:content];

            if ([messageDialog canShow])
            {
                [messageDialog show];
            }
        }];

应用程序显示带有收件人列表的Facebook信使窗口,但是当我选择它们时,“发送”按钮保持不活动状态。

在委托方法中,我没有遇到错误。一切似乎都很好,但我无法发送消息。

行后

content.video = video;
一切似乎都很好:

(lldb) po video.videoURL
assets-library://asset/asset.mov?id=A0F1A001-375B-4708-B2F3-E2CFAFB213A6&ext=mov

(lldb) po content
<FBSDKShareVideoContent: 0x159046b0>

(lldb) po content.video
<FBSDKShareVideo: 0x159533d0>

当我尝试发送链接时 - 一切正常:

        ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
        [library writeVideoAtPathToSavedPhotosAlbum:videoUrl completionBlock:^(NSURL *assetURL, NSError *error) {

            FBSDKShareLinkContent *content = [FBSDKShareLinkContent new];
            content.contentURL = [NSURL URLWithString:@"http://example.com"];
            content.contentTitle = @"title";
            content.contentDescription = @"description";

            FBSDKMessageDialog *messageDialog = [[FBSDKMessageDialog alloc] init];
            messageDialog.delegate = self;
            [messageDialog setShareContent:content];

            if ([messageDialog canShow])
            {
                [messageDialog show];
            }
        }];

enter image description here

并且在同一个班级的Facebook分享中效果很好:

        ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
        [library writeVideoAtPathToSavedPhotosAlbum:videoUrl completionBlock:^(NSURL *assetURL, NSError *error) {

            FBSDKShareVideo *video = [FBSDKShareVideo new];
            video.videoURL = assetURL;
            FBSDKShareVideoContent *content = [FBSDKShareVideoContent new];
            content.video = video;

            [FBSDKShareDialog showFromViewController:self.controller withContent:content delegate:self];
        }];

我做错了什么?

0 个答案:

没有答案