On-site wakeup

On-site wakeup

On Android, the wake-up mechanism is slightly different from iOS as there is no similarly efficient way to register to iBeacon identifiers. Instead, we rely on Android OS Location (information provided by the Android API from a combination of GPS/GSM data). The idea is to define a circular area covering the site of interest which is then registered with Android OS Location. That area is defined on NAOCloud (Site and maps/ Site location) and is represented by a red circle (screenshot below).

Important caveats

  • both Location and Bluetooth must be enabled for the wake-up to happen.
  • If the application gets terminated, it will not be revived by that mechanism until the device leaves the OS Location zone and enters your site again (allow a margin of error of at least twice the area radius). So it is not as fine grained as on iOS where leaving an iBeacon area and entering a new one is enough to get a new callback from the OS). If you are looking at keeping the application alive while on site after the initial wake up, check out Android Foreground Service (beware of battery impact though).

NAOCloud Geofence GPS

How do I activate on site wake-up ?

The following information will need to declare two extra services in AndroidManifest.xml.
The purpose of those two services is to catch geofence GPS Enter/Exit events and to notify your app upon entering the area where beacons are deployed.

<service 
   android:name="com.polestar.naosdk.controllers.AndroidGeofencingService" 
   android:exported="true" 
   android:label="@string/app_name"    
/> <service android:name="com.polestar.models.GeofenceTransition" android:exported="true" android:label="@string/app_name" android:process=":geofencing" /> 

Important: On Android 10, background restrictions continue evoluated (cf. https://docs.nao-cloud.com/docs/misc/android-q-update/). To register your class, you need to have permission ACCESS_BACKGROUND_LOCATION granted.

  • Then you need to implement  a class that extends the abstract class NAOWakeUpNotifier to handle onEnterBeaconArea() event. This event allows to notify the app when user enter area where the beacons are deployed

Note: Since Android 8.0, in order to do Background work, you need to use Foreground services. (cf. https://docs.nao-cloud.com/docs/misc/android-8-update/)

Hence, we have created a surchargeable method called wakeUpNotification() that provides us the notification to display during wakeUp execution.

/**  * Method called to set the notification of the wakeUpController  * which will be used for wakeUp feature when listening for signals  * @return the notification that will be displayed  */ public Notification wakeUpNotification() {    //return an default Notification    ...    return notification; }
  • Finally you have to enable the feature by registering your class that extends NAOWakeUpNotifier:
NAOServicesConfig.enableOnSiteWakeUp(context, api_key, OnSiteWakeUpNotifier.class, new NAOWakeUpRegistrationListener() {

            @Override
            public void onStatusChanged(TNAOWAKEUP_REGISTER_STATUS status, String message) {
                //Receive registration status here
            }
        });

Note: NAOWakeUpRegistrationListener is optionnal
Important: To register your class, you need to have everything synchronized for the API key used (i.e.: NAO SDK data) and permission ACCESS_FINE_LOCATION granted.

  • To disable the feature:
    NAOServicesConfig.disableOnSiteWakeUp(context, api_key,  new NAOWakeUpRegistrationListener() {
            @Override
            public void onStatusChanged(TNAOWAKEUP_REGISTER_STATUS status, String message) {
                //Receive registration status here
            }
        });

Optional: persistence across a device reboot / toggle of Android location

When rebooting the device or turning off and back on the Android Location Provider, geofences are de-registered which disables the wake-up behavior.

a. To ensure the wake-up persistence across those two events, you will need to declare one BroadcastReceiver:

        <receiver
            android:name="com.polestar.models.RegisterGeofenceGPSReceiver"
            android:permission="android.permission.RECEIVE_BOOT_COMPLETED"
            android:enabled="true">
            <intent-filter>
                <action android:name="android.location.PROVIDERS_CHANGED" />
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>

b. You will also need to add a specific permission to enable RegisterGeofenceGPSReceiver in AndroidManifest.xml:

    <!-- optional - needed to start the service on boot for on-site wake-up -->
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    • Related Articles

    • On-site wakeup

      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 ...
    • Moving site

      If your site is moving, the NAO Suite will need some additional information to offer the same capabilities as for static sites, especially to be able to use the phone motion sensors. Prerequisites NAO SDK fully integrated following the existing ...
    • ExitSite Management

      NAOSDK – ExitSite This callback is triggered when the NAO SDK determines that the user is no longer near the site beacons. By default, this interface is notified 5 minutes after the last BLE measurements are received by the NAO SDK. In version 23.03 ...
    • 1. Overview

      Setup workflow A typical Indoor Location setup has 6 steps: Site creation Map import Navigation walkways creation Beacon deployment Calibration and Positioning Database (PDB) generation PDB publication (making it avalable for mobile SDK consumption) ...
    • 10. Teams

      Team management can be done using REST API. API reference: Swagger UI Authentication requires the token of a corporate admin: Create team Use the following request template to create teams curl -X POST --header 'Content-Type: application/json' ...