SDK

Location Services

In this page you'll dive deeper into functionality like using GPS signals to get the user's location or monitor their visits to regions and proximity to BTLE devices. These services will bring a new level of contextuality to your app, allowing you to create geo-triggers to send notifications or categorize users based on their location behaviour.

As mentioned in the Implementation page, if you are going to use location services, you must include the following permissions in your AndroidManifest.xml:

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

Enabling Location

Our plugin will automatically handle permission requests for you which will simplify a lot the way you enable location updates and beacons. To enable location updates and beacons you will need to have a registered device, therefore the best place to enable it would be after device registration:

onDeviceReady: function() {

    ...more code

    Notificare.on('registration', function(deviceId) {

        Notificare.registerDevice(deviceId, function() {

            Notificare.enableLocationUpdates();

        }, function(error) {

        });
    });

    ...more code
});

By doing this, your app will prompt the user with the permission dialog (Android 6 and up) and if the user accepts it, it will start receiving the user location and monitor for visits in any of the regions and beacons you've inserted via the dashboard or API.

Disable Location

Pretty much the same you enable location, you can also stop tracking the user location and region/beacon monitoring by invoking the following method:

Notificare.disableLocationUpdates();