简体   繁体   English

适用于<iOS 5的Twitter和Facebook API

[英]Twitter & Facebook API for < iOS 5

我一直在想,是否有可能使用新的iOS版本内置的新Twitter和Facebook框架发布应用程序,但仍然能够部署到较旧的iOS版本,是否有办法禁用该框架? iOS版本不正确?

In iOS 6 you can integrate both pretty easily like this. 在iOS 6中,您可以像这样轻松地集成两者。 Example

- (IBAction)Facebook:(id)sender
{

    if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {

        SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

        SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result){
            if (result == SLComposeViewControllerResultCancelled) {

                NSLog(@"Cancelled");

            } else

            {
                NSLog(@"Done");
            }

            [controller dismissViewControllerAnimated:YES completion:Nil];
        };
        controller.completionHandler =myBlock;

        [controller setInitialText:@""];

        [self presentViewController:controller animated:YES completion:Nil];
    }
}

You can release an app using Twitter and Facebook but you need to always check the iOS version of the device your app is running on before calling the APIs. 您可以使用Twitter和Facebook发布应用程序,但是在调用API之前,您需要始终检查运行该应用程序的设备的iOS版本。 Your app will be without these features in older iOS versions. 在较旧的iOS版本中,您的应用将没有这些功能。

It's not such a bad idea to cover iOS 5.0 and higher as in June 2012 Apple stated that more than 80% of the devices had iOS 5. You can see it at min 69' in this keynote . 覆盖iOS 5.0及更高版本并不是一个坏主意,2012年6月,苹果表示80%以上的设备都装有iOS5。您可以在本主题演讲的最低69英寸处看到它。

For the list of devices and supported iOS version, you can read this . 有关设备列表和支持的iOS版本,您可以阅读此内容

I recommend you use the Facebook SDK for iOS which provides a level of abstraction over the OS support. 我建议您使用适用于iOSFacebook SDK,它提供了对OS支持的抽象级别。

If configured correctly (for example, marking new frameworks as optional as per here ) this will run on older versions of the OS and will fallback to alternative FB authentication methods, such as via the FB app or a webview, when required. 如果配置正确(例如,按照此处将新框架标记为可选),它将在较早版本的OS上运行,并在需要时回退到其他FB身份验证方法,例如通过FB应用程序或Web视图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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