简体   繁体   中英

Native Facebook share on iOS 6

I was wondering if I need to create a facebook app to do a share on facebook.

I don't want the user to actually login or something like this.

As I see in the facebook docs it says that the prerequisite is to "make sure you already set up Facebook Login". I wanted to know if this is really needed or is something I can by pass, since the user is already logged in on their native facebook app.

I think you are talking about to store id and password of facebook.

you should do it from settings... and also you can check by logic that facebook id and password is entered or not.. if not then session will go for login page otherwise it ll just share the perticular thing.

Hope this Helps you...

Here is what I was talking about:

#pragma mark - Share

- (void)sharingStatus {
    if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
        NSLog(@"service available");
        self.shareButton.enabled = YES;
        self.shareButton.alpha = 1.0f;
    } else {
        self.shareButton.enabled = NO;
        self.shareButton.alpha = 0.5f;
    }
}

- (IBAction)facebookPost:(id)sender {

    if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {

        SLComposeViewController *mySLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];


        NSString *shareText = @"This is my share post!";
        [mySLComposerSheet setInitialText:shareText];

        [mySLComposerSheet addImage:[UIImage imageWithData:[NSData dataWithContentsOfURL:self.imageURL]]];

        [mySLComposerSheet addURL:[NSURL URLWithString:@"http://yourURL.com"]];

        [mySLComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result) {

            switch (result) {
                case SLComposeViewControllerResultCancelled:
                    NSLog(@"Post Canceled");
                    break;
                case SLComposeViewControllerResultDone:
                    NSLog(@"Post Sucessful");
                    break;
                default:
                    break;
            }
        }];

        [self presentViewController:mySLComposerSheet animated:YES completion:nil];
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM