草庐IT

iphone - 如何在不越狱手机的情况下使用私有(private) API 在 iOS 上运行后台进程来同步电子邮件项目

coder 2023-09-22 原文

我正在开发一个类似于联系人、日历的企业应用程序。即使我的应用程序处于后台,我也想同步我的日历和联系人。我也很乐意使用私有(private) API,因为我不会提交到应用商店。请注意,我想在不越狱设备的情况下完成这项工作。

已经发布了一个类似的问题 here我正在创建这个新线程,因为已经发布的线程有针对越狱设备的建议解决方案。

最佳答案

我正在分享我自己问题的答案,因为这可能对其他人有帮助

步骤:

1:在您的 application-info.plist 中添加“Required background modes”键并为其项分配值“App provides Voice over IP services”。

2: 在你的 appdelegate.m 文件中,按照下面的代码片段实现“applicationDidEnterBackground:”方法。

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);
    }];
}

例如,我在给定的时间间隔内打印计数器变量 以下是输出日志消息:

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

关于iphone - 如何在不越狱手机的情况下使用私有(private) API 在 iOS 上运行后台进程来同步电子邮件项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12004150/

有关iphone - 如何在不越狱手机的情况下使用私有(private) API 在 iOS 上运行后台进程来同步电子邮件项目的更多相关文章

  1. ruby - 如何从 ruby​​ 中的字符串运行任意对象方法? - 2

    总的来说,我对ruby​​还比较陌生,我正在为我正在创建的对象编写一些rspec测试用例。许多测试用例都非常基础,我只是想确保正确填充和返回值。我想知道是否有办法使用循环结构来执行此操作。不必为我要测试的每个方法都设置一个assertEquals。例如:describeitem,"TestingtheItem"doit"willhaveanullvaluetostart"doitem=Item.new#HereIcoulddotheitem.name.shouldbe_nil#thenIcoulddoitem.category.shouldbe_nilendend但我想要一些方法来使用

  2. ruby - 为什么我可以在 Ruby 中使用 Object#send 访问私有(private)/ protected 方法? - 2

    类classAprivatedeffooputs:fooendpublicdefbarputs:barendprivatedefzimputs:zimendprotecteddefdibputs:dibendendA的实例a=A.new测试a.foorescueputs:faila.barrescueputs:faila.zimrescueputs:faila.dibrescueputs:faila.gazrescueputs:fail测试输出failbarfailfailfail.发送测试[:foo,:bar,:zim,:dib,:gaz].each{|m|a.send(m)resc

  3. ruby - 如何在 Ruby 中顺序创建 PI - 2

    出于纯粹的兴趣,我很好奇如何按顺序创建PI,而不是在过程结果之后生成数字,而是让数字在过程本身生成时显示。如果是这种情况,那么数字可以自行产生,我可以对以前看到的数字实现垃圾收集,从而创建一个无限系列。结果只是在Pi系列之后每秒生成一个数字。这是我通过互联网筛选的结果:这是流行的计算机友好算法,类机器算法:defarccot(x,unity)xpow=unity/xn=1sign=1sum=0loopdoterm=xpow/nbreakifterm==0sum+=sign*(xpow/n)xpow/=x*xn+=2sign=-signendsumenddefcalc_pi(digits

  4. ruby - 具有身份验证的私有(private) Ruby Gem 服务器 - 2

    我想安装一个带有一些身份验证的私有(private)Rubygem服务器。我希望能够使用公共(public)Ubuntu服务器托管内部gem。我读到了http://docs.rubygems.org/read/chapter/18.但是那个没有身份验证-如我所见。然后我读到了https://github.com/cwninja/geminabox.但是当我使用基本身份验证(他们在他们的Wiki中有)时,它会提示从我的服务器获取源。所以。如何制作带有身份验证的私有(private)Rubygem服务器?这是不可能的吗?谢谢。编辑:Geminabox问题。我尝试“捆绑”以安装新的gem..

  5. ruby - 如何在 buildr 项目中使用 Ruby 代码? - 2

    如何在buildr项目中使用Ruby?我在很多不同的项目中使用过Ruby、JRuby、Java和Clojure。我目前正在使用我的标准Ruby开发一个模拟应用程序,我想尝试使用Clojure后端(我确实喜欢功能代码)以及JRubygui和测试套件。我还可以看到在未来的不同项目中使用Scala作为后端。我想我要为我的项目尝试一下buildr(http://buildr.apache.org/),但我注意到buildr似乎没有设置为在项目中使用JRuby代码本身!这看起来有点傻,因为该工具旨在统一通用的JVM语言并且是在ruby中构建的。除了将输出的jar包含在一个独特的、仅限ruby​​

  6. ruby - 什么是填充的 Base64 编码字符串以及如何在 ruby​​ 中生成它们? - 2

    我正在使用的第三方API的文档状态:"[O]urAPIonlyacceptspaddedBase64encodedstrings."什么是“填充的Base64编码字符串”以及如何在Ruby中生成它们。下面的代码是我第一次尝试创建转换为Base64的JSON格式数据。xa=Base64.encode64(a.to_json) 最佳答案 他们说的padding其实就是Base64本身的一部分。它是末尾的“=”和“==”。Base64将3个字节的数据包编码为4个编码字符。所以如果你的输入数据有长度n和n%3=1=>"=="末尾用于填充n%

  7. ruby - 如何每月在 Heroku 运行一次 Scheduler 插件? - 2

    在选择我想要运行操作的频率时,唯一的选项是“每天”、“每小时”和“每10分钟”。谢谢!我想为我的Rails3.1应用程序运行调度程序。 最佳答案 这不是一个优雅的解决方案,但您可以安排它每天运行,并在实际开始工作之前检查日期是否为当月的第一天。 关于ruby-如何每月在Heroku运行一次Scheduler插件?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/8692687/

  8. ruby-on-rails - 如何在 ruby​​ 中使用两个参数异步运行 exe? - 2

    exe应该在我打开页面时运行。异步进程需要运行。有什么方法可以在ruby​​中使用两个参数异步运行exe吗?我已经尝试过ruby​​命令-system()、exec()但它正在等待过程完成。我需要用参数启动exe,无需等待进程完成是否有任何ruby​​gems会支持我的问题? 最佳答案 您可以使用Process.spawn和Process.wait2:pid=Process.spawn'your.exe','--option'#Later...pid,status=Process.wait2pid您的程序将作为解释器的子进程执行。除

  9. ruby - 无法运行 Rails 2.x 应用程序 - 2

    我尝试运行2.x应用程序。我使用rvm并为此应用程序设置其他版本的ruby​​:$rvmuseree-1.8.7-head我尝试运行服务器,然后出现很多错误:$script/serverNOTE:Gem.source_indexisdeprecated,useSpecification.Itwillberemovedonorafter2011-11-01.Gem.source_indexcalledfrom/Users/serg/rails_projects_terminal/work_proj/spohelp/config/../vendor/rails/railties/lib/r

  10. ruby - 在 jRuby 中使用 'fork' 生成进程的替代方案? - 2

    在MRIRuby中我可以这样做:deftransferinternal_server=self.init_serverpid=forkdointernal_server.runend#Maketheserverprocessrunindependently.Process.detach(pid)internal_client=self.init_client#Dootherstuffwithconnectingtointernal_server...internal_client.post('somedata')ensure#KillserverProcess.kill('KILL',

随机推荐