0

I have an android/iOS app (iOS>9.0 swift & Objective-C) that works almost all the time in background. It has the background modes active for Audio, Location and Uses Bluetooth LE accesories. Is a self-security app, and when it runs in background it detects the presence of registered UUID Bluetooth LE devices, and if the user specifically turns off the bluetooth of the iPhone, or changes the location permissions (General or my app) it is warned with a UNNotification that the app won't work if that service is off. (I detect that with CLLocationManager.locationServicesEnabled() and the method didChangeAuthorization for the CLLocationManagerDelegate)

The question is: is there a mechanism for checking the same when the app is killed or not running in background?

I've been searching a lot about background modes, silent notifications, to perform some code when the notification arrives, but that won't work, because, as far as I know, the notification needs user interaction for doing other things apart from playing sound or show a message.

I've read as well a lot of docs from apple and I have found nothing. Does somebody knows if it is possible to do that kind of checking? (without jailbreaking the phone, of course)

Edited: is not the same as How do you constantly run in background? because my app must run in background or killed. It must be checking for a certain region all the time.

CarlosGT
  • 1
  • 2
  • You can't do _anything_ if your code isn't running, but there are ways to get execution time. – jscs Jan 11 '18 at 19:01
  • Thank you, John, I was getting to that point, but I had hope in some mechanism that wake up the app to do those checks, like the location Manager startMonitoring works. You can have the app killed and when the region you want is visible, the app is waked up. I think I will have to put a disclaimer saying that If you kill the app, the sistem might not work if the location/bluetooth is turned off. – CarlosGT Jan 12 '18 at 07:29
  • In addition to that disclaimer, I recently discovered -- to my amazement -- that you can post a user notification from applicationDidTerminate: (may not be 100% reliable). You could try that to get the user to relaunch the app for you. – jscs Jan 12 '18 at 13:38
  • If I were to unmark this as duplicate, the answer would just be "no", so I'm not sure how that would be useful. The way that you solve the core problem that you have is just to get background execution time in as many ways as possible. – jscs Jan 12 '18 at 13:39
  • Yes, I am doing more or les this thing right now, putting a notification in applicationDidTerminate telling the user that the app will work, unless BT and location services are turned off...is not the best way to proceed...but is better than nothing. Another time, thank for your help, John – CarlosGT Jan 15 '18 at 11:20

0 Answers0