0

I've searched this for a while, but I cannot find a clear guide with what SDK to use and what steps to follow. It seems I should first register my usage in Info.plist, and I can use something like NSTimer to achieve it. Is this correct?

Some material mention only specific type app can enable background service for a long time. My app is not in those types, but I think it's not a problem if I'm not going to submit it to AppStore? In info.plist can I register the usage as any type in my case?

Thanks!

Further information if needed: I'm working on a heath care app. Now it simulates the health care sensor using pre-stored sensor data, so it needs to continuously (a least per second) read the data even when the program is in the background (so that it can respond when sensor identifies abnormal situation). It's just a prototype app, so consuming resource is not a problem.

Li-Fan Yu
  • 305
  • 1
  • 3
  • 8
  • How is your app connected to your sensor? Via Bluetooth or IP (WiFi)? – Paulw11 Mar 09 '15 at 09:49
  • It's only for prototyping now, so it doesn't connect to the sensor. I simulate the sensor using a pre-stored CSV file. – Li-Fan Yu Mar 09 '15 at 10:01
  • Probably playing background audio (you can simply play silence) is the best way to keep your app running as long as you don't need app store approval – Paulw11 Mar 09 '15 at 10:13

1 Answers1

2

You can utilize the M7 coprocessor (iPhone 5S, 6, 6 Plus), which enables you to get programmatically notified as the user goes from stationary to running, walking using CMMotionActivityManager.

With pre M7 devices, you could:

  • use the Info.plist background audio trick to stay awake, you can check out this tutorial for that.

  • use an NSTimer to make periodical location updates before the application is sent to the suspended state by the OS, check out this answer

Community
  • 1
  • 1
Ivan
  • 497
  • 4
  • 11