Skip to content

Location Based Notifications

Before you start:

  • You must add the NSLocationAlwaysUsageDescription or NSLocationWhenInUseUsageDescription in the project ios/<YourAppName>/Info.plist
  • For iOS 11 you must add the NSLocationAlwaysAndWhenInUseUsageDescription in the project ios/<YourAppName>/Info.plist
  • If beacons are implied in your use case, we suggest you to add the NSBluetoothPeripheralUsageDescription string too.

Request permissions

You can check and ask for notification and location permissions using our drop-in permission dialog:

import NearIT, { NearItConstants } from 'react-native-nearit'
const { Permissions } = NearItConstants

// get permissions status
const location = await NearIT.isLocationGranted();
const notifications = await NearIT.isNotificationGranted();
const locationServices = await NearIT.areLocationServicesOn();
const bluetooth = await NearIT.isBluetoothEnabled();

// usage example
if (location != Permissions.always) {
  const result = await NearIT.requestPermissions("Optional explanation text")
  if (result.location == Permissions.always) {
    console.log("Location permission granted:", result.location, " --> Will start radar");
  } else {
    // do NOT start radar if location permission is NOT granted!

If you need an all-in-one utility library to check location and bluetooth services, please check this module out.