Ad

IOS - FB Sharing Opens Safari Dialog Box For Login

- 1 answer

So, in my app I can successfully share content. I have a question though.

  1. User has not logged in FB from anywhere in the app
  2. User has the FB app installed on his phone.
  3. When I click share, I am being prompted to login using the FB in safari.

Can I skip no.3? And let the user get the login details from FB app on his phone?

All I do for sharing is :

-(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];
}
Ad

Answer

If you want only share why don't use SLComposeViewController? Is native and don't use safari. Also works with twitter.

import Social

Create the 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)
}
Ad
source: stackoverflow.com
Ad