iOS provides a way to register an app with BLE beacons in such a way that even if the app is not running, a callback will be triggered when a user enters or exits the vicinity of a beacon.. Bluetooth must be active for the wake-up to work.
To activate it, you need to call :
[NAOServicesConfig enableOnSiteWakeUp];
All regions associated with your app are tracked at all times, including when the app isn’t running. If a region boundary is crossed while an app isn’t running, that app is relaunched into the background to handle the event. Similarly, if the app is suspended when the event occurs, it’s woken up and given a short amount of time (around 10 seconds) to handle the event. So app will have to start nao service if need to stay working in background.
If nao service is not started at the launch of the application, you have to implement the method bellow to start nao service.
Add some code in the AppDelegate didFinishLaunchingWithOptions method:
if ([launchOptions objectForKey:UIApplicationLaunchOptionsLocationKey]) {
// code that gets called on a wake-up here.
// and start nao service if need
}
To turn-off the wake-up, call:
[NAOServicesConfig disableOnSiteWakeUp];
On-site wake-up behavior is turned on by default: if your app is killed before all services are stopped, didFinishLaunchingWithOptions will be called even if you didn’t call [NAOServicesConfig enableOnSiteWakeUp];
So, if your application does not support the on site wake-up, you will have to add the code below. This allow to not execute code when the app is woken up on site
if ([launchOptions objectForKey:UIApplicationLaunchOptionsLocationKey]) {
// Do nothing if the application does not support wake-up (call return)
}
Here are some reasons why wakeup not be available: