如何在iOS 7应用上启用后台更新

如何在iOS 7应用上启用后台更新,第1张

概述如何让我的应用程序使用iOS 7后台更新功能?我注意到一些应用程序已经这样做了,但它似乎并不是全自动的. 根据 What’s New in iOS 7,你正在寻找的是: Apps that regularly update their content by contacting a server can register with the system and be launched period 如何让我的应用程序使用iOS 7后台更新功能?我注意到一些应用程序已经这样做了,但它似乎并不是全自动的.解决方法 根据 What’s New in iOS 7,你正在寻找的是:

Apps that regularly update their content by contacting a server can
register with the system and be launched periodically to retrIEve that
content in the background. To register,include the uibackgroundmodes
key with the fetch value in your app’s Info.pList file. Then,when
your app is launched,call the setMinimumBackgroundFetchInterval:
method to determine how often it receives update messages. Finally,
you must also implement the
application:performFetchWithCompletionHandler: method in your app
delegate.

在内部,application:performFetchWithCompletionHandler:,在你必须调用completionHandler之前,总共需要30秒才能完成你需要做的事情.绝对建议尽快执行您的民意调查,并在完成执行后立即调用completionHandler.如果您未在指定的30秒内调用它,您的应用将暂停从后台获取.或者,如果您开始花费很长时间进行每次提取,那么您的应用将来获得后台提取的机会将会减少.

或者,如果您希望在收到推送通知时执行其他代码:

Apps that use push notifications to notify the user that new content
is available can fetch the content in the background. To support this
mode,include the uibackgroundmodes key with the remote-notification
value in your app’s Info.pList file. You must also implement the
application:dIDReceiveRemoteNotification:fetchCompletionHandler: method in your app delegate.

总结

以上是内存溢出为你收集整理的如何在iOS 7应用上启用后台更新全部内容,希望文章能够帮你解决如何在iOS 7应用上启用后台更新所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1098357.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存