IOS - FB共享打开safari对话框进行登录

gho*_*der 7 facebook facebook-graph-api ios

所以,在我的应用程序中,我可以成功分享内容.但我有个问题.

  1. 用户尚未从应用程序中的任何位置登录FB
  2. 用户在手机上安装了FB应用程序.
  3. 当我单击共享时,系统会提示我在Safari中使用FB登录.

我可以跳过3号吗?让用户通过手机上的FB应用程序获取登录详细信息?

我所做的一切就是:

-(void) userTappedOnFBLink:(UIGestureRecognizer*)gestureRecognizer
{
    NSLog(@"FB share");

    FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
    content.contentURL = [NSURL URLWithString:SHARE_URL];

    [FBSDKShareDialog showFromViewController:self.parentViewController
                                 withContent:content
                                    delegate:self];
}
Run Code Online (Sandbox Code Playgroud)

Kev*_*rio 3

如果你只想分享为什么不使用 SLComposeViewController?是原生的,不使用 safari。也适用于推特。

import Social
Run Code Online (Sandbox Code Playgroud)

创建 SLComposeViewController:

if let vc = SLComposeViewController(forServiceType: SLServiceTypeFacebook) {
    vc.setInitialText("Your post text") //Optional
    vc.add(UIImage(named: "YourImageName")!) //Optional
    vc.add(URL(string: "Your url")) //Optional
    present(vc, animated: true)
}
Run Code Online (Sandbox Code Playgroud)