我开发的应用程序应该每 15 分钟处理一次数据.所以我在 plist 文件中添加了 voip 标志.并使用 900 秒(15 分钟)的 setKeepAliveTimeout.还添加了处理一些数据的后台任务功能.处理数据最多需要 10 秒.
I've developed app which should process some data every 15 min. So I added voip flag into plist file. And use setKeepAliveTimeout with 900 sec(15 min). Also added background task functionality which processes some data. Processing of data takes up to 10 seconds.
问题是应用没有及时唤醒.有时在 12 分钟后,有时在 16 分钟后等等.但我需要正好在 15 分钟内.
The problem is that app wakes up NOT in time. Sometimes after 12 min, sometimes after 16 min etc. But I need exactly in 15 min.
如何解决以下问题?
iOS版本为5.0+
如果是 iOS 特定的,请向我提供有关苹果 api 文档的官方参考.
If it's iOS's specific please provide me official reference into the apple's api document where this mentioned .
setKeepAliveTimeout:handler:
不是通用的间隔调度程序.它允许您设置提供的处理程序的调用之间的最大间隔.该功能的目的是帮助您防止连接超时或落后于您的 VOIP 应用程序标准(例如在线/离开状态).
setKeepAliveTimeout:handler:
is not a general purpose interval scheduler. It allows you to set the maximum interval between invocations of the supplied handler. The purpose of the function is to help you keep your connections from timing out or falling behind your VOIP applications standards (for things like online/away status).
所以第一个参数 (timeout
) 告诉 iOS 在不超过 15 分钟内调用您的处理程序.如果操作系统决定在 12 分钟内有一些空闲周期,它可能会调用您的处理程序.或者在 7 分钟内,或者 15 分钟内.
So the first parameter (timeout
) tells iOS to call your handler in no more than 15 minutes. If the OS decides that it's got some cycles to spare at 12 minutes, it might call your handler. Or in 7 minutes, or 15.
如果您需要对间隔进行更精细的控制,您应该设置一个较小的超时窗口并忽略对您不重要的调用.但是调用仍然会相当不规则.
If you need finer grained control of the interval, you should set a smaller timeout window and just ignore invocations that aren't important to you. But the invocations will still going be fairly irregular.
http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIApplication_Class/Reference/Reference.html#//apple_ref/occ/instm/UIApplication/setKeepAliveTimeout:handler:
一般来说,目前没有办法让它按精确的时间表唤醒您的应用.您必须遵守 iOS 有限的后台处理选项,所有这些选项都旨在为操作系统提供很大的余地来管理所有进程的总体优先级和资源需求.
In general, there is currently no way to make it wake your app on a precise schedule. You must adhere to iOS' limited background processing options, all of which are designed to give the OS a lot of leeway to manage overall priorities and resource needs across ALL processes.
这篇关于如果为 setKeepAliveTimeout 方法设置 15 分钟,VOIP 应用程序不会及时唤醒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!