sha*_*thi 6 iphone background-process iphone-privateapi ios
我正在开发一个类似于联系人,日历的企业应用程序.即使我的应用程序在后台,我也想同步我的日历和联系人.我也很高兴使用私有API,因为我不会提交给应用程序商店.请注意,我想在没有越狱设备的情况下完成这项工作.
我正在为自己的问题分享答案,因为这可能有助于其他人
脚步:
static int counter;
- (void)applicationDidEnterBackground:(UIApplication *)application
{
//Minimun keepAliveTimeout is 600 seconds
[[UIApplication sharedApplication] setKeepAliveTimeout:605 handler:^{
//do your task
counter ++;
NSLog(@"Counter # %d", counter);
}];
}
Run Code Online (Sandbox Code Playgroud)
例如,我在给定的时间间隔内打印计数器变量.下面是输出日志消息:
2012-08-27 14:06:09.216 BackgroundApplicationForVOIP[1129:207] Counter # 1
2012-08-27 14:16:14.218 BackgroundApplicationForVOIP[1129:207] Counter # 2
2012-08-27 14:26:19.219 BackgroundApplicationForVOIP[1129:207] Counter # 3
2012-08-27 14:36:24.220 BackgroundApplicationForVOIP[1129:207] Counter # 4
2012-08-27 14:46:29.221 BackgroundApplicationForVOIP[1129:207] Counter # 5
2012-08-27 14:54:21.000 BackgroundApplicationForVOIP[1129:207] Counter # 6
2012-08-27 15:19:48.099 BackgroundApplicationForVOIP[1129:207] Counter # 7
2012-08-27 15:26:03.201 BackgroundApplicationForVOIP[1129:207] Counter # 8
2012-08-27 15:39:50.167 BackgroundApplicationForVOIP[1129:207] Counter # 9
2012-08-27 16:07:28.112 BackgroundApplicationForVOIP[1129:207] Counter # 10
2012-08-27 16:13:43.217 BackgroundApplicationForVOIP[1129:207] Counter # 11
2012-08-27 16:23:48.218 BackgroundApplicationForVOIP[1129:207] Counter # 12
2012-08-27 16:33:53.219 BackgroundApplicationForVOIP[1129:207] Counter # 13
2012-08-27 16:43:58.220 BackgroundApplicationForVOIP[1129:207] Counter # 14
2012-08-27 16:54:03.221 BackgroundApplicationForVOIP[1129:207] Counter # 15
Run Code Online (Sandbox Code Playgroud)
如果这是一个企业应用程序而您没有提交给Apple,那么我会探索让您的应用程序将自己标识为VOIP应用程序.然后,您可以设置keepAliveTimer,并在后台获得定期处理时间,以满足您的需求.
| 归档时间: |
|
| 查看次数: |
3372 次 |
| 最近记录: |