Xcode Swift 4 Facebook & Twitter sharing no longer working?

后端 未结 3 2052
萌比男神i
萌比男神i 2021-01-24 05:00

i am using Facebook & Twitter sharing in my app , after upgrade xCode to 9.0.1 Swift 4, both are not working , the method saying i have no FB or Tw account on my device but

相关标签:
3条回答
  • 2021-01-24 05:37

    You have to use Facebook's SDK to share: FBSDKShareKit

    You can install it using cocoa pods:

    pod 'FBSDKShareKit'
    

    Example

    #import <FBSDKShareKit/FBSDKShareKit.h>
    
    -(IBAction)sharingOnFacebook:(id)sender {
         FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
         content.contentURL = [NSURL URLWithString:@"https://myPageWeb/"];
    
        [FBSDKShareDialog showFromViewController:self withContent:content delegate:nil];
    }
    

    And for Twitter the steps are similar: TwitterKit

    pod 'TwitterKit'
    

    Example:

    -(IBAction)sharingOnTwitter:(id)sender {
        TWTRComposer *composer = [[TWTRComposer alloc] init];
        [composer setURL:[NSURL URLWithString:@"https://https://myPageWeb/"]];
        [composer showFromViewController:self completion:^(TWTRComposerResult result) {
            /*if (result == TWTRComposerResultCancelled) {
                NSLog(@"Tweet composition cancelled");
            } else {
                NSLog(@"Sending Tweet!");
            }*/
        }];
    }
    

    NOTE: Read Facebook and Twitter documentation because you need to do some steps for your app previously. Register the app, get the AppID...

    Facebook iOS Developers

    Twitter iOS Developers page

    0 讨论(0)
  • 2021-01-24 05:39

    Those have been disabled with iOS 11. You should no longer see the Facebook NOR twitter sub-menus in the iOS Settings app.

    I would suggest you to use the regular sharing options or the fb/twitter APIs.

    Vincent

    0 讨论(0)
  • 2021-01-24 05:59

    Dont check if its available anymore; isAvailable(forServiceType:), just run it direct. I faced similar issue myself

    0 讨论(0)
提交回复
热议问题