首先,我必须说,我对在应用商店中发布不感兴趣,但同时我对越狱我的手机不感兴趣。
我想尝试在后台执行代码,因此我想编写一个简单的应用程序来定期记录我的电池电量和位置,假设每 10 分钟记录一次。我不想安排本地通知,所以据我了解,这只能(?)去 'Pastebot 方式'。
有人可以给我更多相关信息吗?如果我想测试它,我是否必须安排计时器并正确配置我的音频会话?或者,换句话说,我不明白我的“后台执行代码”应该放在哪里。任何帮助/信息都非常感谢!
First of all, I have to say that I am not interested in publishing in the appstore, but at the same time I am not interested in jailbreaking my phone.
I want to experiment with code execution in the background, so I'd like to write a simple application that periodically logs my battery level and my position, let's say every 10 minutes. I don't want to schedule local notifications, so to my understanding, this would only be possible (?) going the 'Pastebot way'.
Can someone please give me more information about that? If I want to test it, will I have to schedule a timer and properly configure my audio session? Or, in other words, I don't understand where my "background executing code" should be placed. Any help/information highly appreciated!
发布评论
评论(1)
如果您想使用位置服务,则可以在应用程序 info.plist 中设置应用程序后台模式(UIBackgroundModes 并向其添加 location 项)。并在您的应用程序中开始监视位置变化。就是这样,您的应用程序不会被挂起(直到系统因其他进程的内存而处于繁重的位置)。
If you want to use location services, than you can set your application background mode in app info.plist (UIBackgroundModes and add to it location item). And in your application start monitoring location change. Thats it, your application won't be suspended (till system will be in heavy position with memory for other process).