Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IOS - FB sharing opens safari dialog box for login

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];
}
like image 326
ghostrider Avatar asked Jan 06 '18 16:01

ghostrider


1 Answers

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)
}
like image 134
Kevinosaurio Avatar answered Oct 13 '22 03:10

Kevinosaurio