适用于ios 5和ios 6的Facebook集成

use*_*099 5 iphone xcode facebook objective-c ios

我想将ios 5和ios 6整合在一起.

我知道将facebook整合到个人ios(即ios 5或ios 6)中,但不知道如何支持ios 5和ios 6的facebook.

换句话说,如何为ios 5和ios 6整合facebook?或者在两个ios中支持这个的常用方法是什么?

谢谢

Zen*_*Zen 16

好吧,如果你想在iOS6中使用facebook集成,如果iOS版本低于6,你想使用Facebook SDK for iOS,你可以检查集成的Facebook服务类的可用性Social Framework.你也必须导入Social Framework它.

#import<Social/Social.h>
Run Code Online (Sandbox Code Playgroud)

您可以通过buttonAction方法中的类似内容检查集成的Facebook服务的可用性

- (void)buttonAction:(id)sender
{
    //Check for availability of Facebook integration and use its view controller to share on Facebook
    if(NSClassFromString(@"SLComposeViewController") != nil) {
        SLComposeViewController *fbController=[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
        if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
            //Use fbController for sharing
        } else {
            // Service not available
        }
    }
    else{
        // Use your code for sharing on iOS versions other than 6.x to authenticate and get an access token.
    }
}
Run Code Online (Sandbox Code Playgroud)

希望它有所帮助.

  • 将您的`Social Framework`作为可选框架.不要使它成为一个必需的框架.对于iOS <6,它不会被要求 (2认同)