好的,我正在查看SimpleBackgroundFetch示例项目,它在App Delegate中使用以下内容:
[[UIApplication sharedApplication] setMinimumBackgroundFetchInterval:someTimeInSeconds]; //^this code is in didFinishLaunchingWithOptions -(void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { //do something + call completionHandler depending on new data / no data / fail }
所以,基本上我假设,我在这里调用我的应用程序服务器,以获取一些数据.
但后来我看到了NSURLSession docs,它有这样的方法
– downloadTaskWithURL:
并说它如下:
This API provides a rich set of delegate methods for supporting
authentication and gives your app the ability to perform background
downloads when your app is not running or,in iOS,while your app is
suspended.
那么这两个API之间的区别是什么?如果我想不时地从我的应用程序的服务器下载一些数据,我应该使用什么?
我只是不确定两者之间的区别,所以我只是觉得我应该在这里澄清我的怀疑.去StackOverflow!
解决方法
这些是完全不同的东西.
>后台获取:系统会在某个时间启动您的应用程序(启发式),您的工作就是开始为用户下载新内容.> NSURLSession:NSURLConnection的替换,允许在应用程序暂停后继续下载.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。