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.

Tracking a user location in iOS will require the user's authorization, this means that your app must declare usage description texts explaining why it needs to track location. For older versions of iOS you may optionally declare the key NSLocationUsageDescription in your app's .plist file. In iOS8 and higher, is it mandatory the use of the key NSLocationAlwaysUsageDescription. In iOS 11 a new permission was introduced and you are required to include both NSLocationAlwaysAndWhenInUseUsageDescription and NSLocationWhenInUseUsageDescription in your app's .plist file. Bottom line if you are supporting iOS 7 and up you'll need to include the following in your app's .plist file:

ios location privacy plist entries

Make sure you provide a text that best describes why and how you are going to use the user’s location. This text will be displayed to the user the first time you request the use of location services. Users are more likely to trust your app with location data if they understand why you need it.

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();