Why suddenly my iOS app can not post status update to Facebook

余生长醉 提交于 2019-12-06 08:45:07

I decided to use iOS6 feature SLComposeViewController, which makes posting Facebook status update a piece of cake.

After add Social framework in your .m file, you can do sth like this:

    - (IBAction)clickMe:(UIButton *)sender {
         NSLog(@"you clicked me");
         if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {

       SLComposeViewController* myFB = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];


          SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result) {
            if (result == SLComposeViewControllerResultCancelled) {
                NSLog(@"cancelled");
           } else {
               NSLog(@"oh yeah");
           }
        [myFB dismissViewControllerAnimated:YES completion:nil];
    };
    myFB.completionHandler = myBlock;
    [myFB setInitialText:@"Posting from my app."];
    [self presentViewController:myFB animated:YES completion:nil];

    }

    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!