2

我已经向 Facebook 分享了一些内容,为此我正在使用这个 POC。

NSString *title = @"Some Title";
NSString *shareBody =[NSString stringWithFormat:@"%@\nI have rated %@ as %zd/5", self.commentTextView.text, store.name, self.rating];

NSString *storeID = store.ID.description;

FBSDKShareLinkContent *content = [FBSDKShareLinkContent new];
content.contentTitle = title;
content.contentDescription = shareBody;
content.imageURL = [NSURL URLWithString:store.coverImage.medium];
content.placeID = storeID;
content.contentURL = [NSURL URLWithString:[NSString stringWithFormat:@"https://fb.me/ 137144****85103?store=%@", store.ID]];

FBSDKShareDialog* dialog = [FBSDKShareDialog new];
dialog.delegate = self;
dialog.shareContent = content;
dialog.mode = FBSDKShareDialogModeBrowser;
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"fbauth2://"]])
    dialog.mode = FBSDKShareDialogModeAutomatic;
dialog.fromViewController = [UIApplication sharedApplication].keyWindow.rootViewController;

无论是否安装了 Facebook 应用程序,帖子都会成功分享到 Facebook。

第一种情况是当我使用 Facebook 应用程序并单击共享帖子时,它会打开我的应用程序(如果已安装)或将我带到 iTunes URL。

第二种情况是我的手机上没有安装 Facebook 应用程序,我使用 safari 来查看 Facebook,然后单击该帖子。它试图打开网址,但再次将我重定向到 facebook.com。

第三种情况是我的手机上安装了 Facebook 应用程序,但我仍然使用 safari 来查看 Facebook,然后单击该帖子,它会打开 facebook 应用程序而不是我的应用程序。

我需要案例 2 和 3 的帮助。请告知?

4

0 回答 0