react-native-notificare-geo
Version:
Notificare Geo React Native module.
219 lines • 10.4 kB
TypeScript
import { type EmitterSubscription } from 'react-native';
import type { NotificareLocation } from './models/notificare-location';
import type { NotificareRegion } from './models/notificare-region';
import type { NotificareBeacon } from './models/notificare-beacon';
import type { NotificareVisit } from './models/notificare-visit';
import type { NotificareHeading } from './models/notificare-heading';
export declare class NotificareGeo {
private static readonly eventEmitter;
/**
* Indicates whether location services are enabled.
*
* @returns {Promise<boolean>} - A promise that resolves to `true` if the
* location services are enabled by the application, and `false` otherwise.
*/
static hasLocationServicesEnabled(): Promise<boolean>;
/**
* Indicates whether Bluetooth is enabled.
*
* @returns {Promise<boolean>} - A promise that resolves to `true` if Bluetooth
* is enabled and available for beacon detection and ranging, and `false` otherwise.
*/
static hasBluetoothEnabled(): Promise<boolean>;
/**
* Provides a list of regions currently being monitored.
*
* @returns {Promise<NotificareRegion[]>} - A promise that resolves to a list
* of {@link NotificareRegion} objects representing the geographical regions
* being actively monitored for entry and exit events.
*/
static getMonitoredRegions(): Promise<NotificareRegion[]>;
/**
* Provides a list of regions the user has entered.
*
* @returns {Promise<NotificareRegion[]>} - A promise that resolves to a list
* of {@link NotificareRegion} objects representing the regions that the user
* has entered and not yet exited.
*/
static getEnteredRegions(): Promise<NotificareRegion[]>;
/**
* Enables location updates, activating location tracking, region monitoring,
* and beacon detection.
*
* **Note**: This function requires explicit location permissions from the user.
* Starting with Android 10 (API level 29), background location access requires
* the ACCESS_BACKGROUND_LOCATION permission. For beacon detection, Bluetooth
* permissions are also necessary. Ensure all permissions are requested before
* invoking this method.
*
* The behavior varies based on granted permissions:
* - **Permission denied**: Clears the device's location information.
* - **When In Use permission granted**: Tracks location only while the
* app is in use.
* - **Always permission granted**: Enables geofencing capabilities.
* - **Always + Bluetooth permissions granted**: Enables geofencing
* and beacon detection.
*
* @returns {Promise<void>} - A promise that resolves when location updates
* have been successfully enabled.
*/
static enableLocationUpdates(): Promise<void>;
/**
* Disables location updates.
*
* This method stops receiving location updates, monitoring regions, and
* detecting nearby beacons.
*
* @returns {Promise<void>} - A promise that resolves when location updates
* have been successfully disabled.
*/
static disableLocationUpdates(): Promise<void>;
/**
* Sets a callback that will be invoked when an onLocationUpdated event is
* triggered in the background.
*
* @param callback - A callback that will be invoked with the result of the
* onLocationUpdated event, when in background. It will provide the updated
* {@link NotificareLocation} object representing the user's new location.
*/
static setLocationUpdatedBackgroundCallback(callback: (location: NotificareLocation) => Promise<void>): void;
/**
* Sets a callback that will be invoked when an onRegionEntered event is
* triggered in the background.
*
* @param callback - A callback that will be invoked with the result of the
* onRegionEntered event. It will provide the {@link NotificareRegion}
* representing the region the user has entered.
*/
static setRegionEnteredBackgroundCallback(callback: (region: NotificareRegion) => Promise<void>): void;
/**
* Sets a callback that will be invoked when an onRegionExited event is
* triggered in the background.
*
* @param callback - A callback that will be invoked with the result of the
* onRegionExited event. It will provide the {@link NotificareRegion}
* representing the region the user has exited.
*/
static setRegionExitedBackgroundCallback(callback: (region: NotificareRegion) => Promise<void>): void;
/**
* Sets a callback that will be invoked when an onBeaconsEntered event is
* triggered in the background.
*
* @param callback - A callback that will be invoked with the result of the
* onBeaconEntered event. It will provide the {@link NotificareBeacon}
* representing the beacon the user has entered the proximity of.
*/
static setBeaconEnteredBackgroundCallback(callback: (beacon: NotificareBeacon) => Promise<void>): void;
/**
* Sets a callback that will be invoked when an onBeaconsExited event is
* triggered in the background.
*
* @param callback - A callback that will be invoked with the result of the
* onBeaconExited event. It will provide the {@link NotificareBeacon}
* representing the beacon the user has exited the proximity of.
*/
static setBeaconExitedBackgroundCallback(callback: (beacon: NotificareBeacon) => Promise<void>): void;
/**
* Sets a callback that will be invoked when an onBeaconsRanged event is
* triggered in the background.
*
* @param callback - A callback that will be invoked with the result of the
* onBeaconsRanged event. It will provide a list of {@link NotificareBeacon}
* that were detected and the {@link NotificareRegion} where they were detected.
*/
static setBeaconsRangedBackgroundCallback(callback: (data: {
region: NotificareRegion;
beacons: NotificareBeacon[];
}) => Promise<void>): void;
/**
* Called when a new location update is received.
*
* @param callback - A callback that will be invoked with the result of the
* onLocationUpdated event. It will provide the updated {@link NotificareLocation}
* object representing the user's new location.
* @returns {EmitterSubscription} - The {@link EmitterSubscription} for the
* onLocationUpdated event.
*/
static onLocationUpdated(callback: (location: NotificareLocation) => void): EmitterSubscription;
/**
* Called when the user enters a monitored region.
*
* @param callback - A callback that will be invoked with the result of the
* onRegionEntered event. It will provide the {@link NotificareRegion}
* representing the region the user has entered.
* @returns {EmitterSubscription} - The {@link EmitterSubscription} for the
* onRegionEntered event.
*/
static onRegionEntered(callback: (region: NotificareRegion) => void): EmitterSubscription;
/**
* Called when the user exits a monitored region.
*
* @param callback - A callback that will be invoked with the result of the
* onRegionExited event. It will provide the {@link NotificareRegion}
* representing the region the user has exited.
* @returns {EmitterSubscription} - The {@link EmitterSubscription} for the
* onRegionExited event.
*/
static onRegionExited(callback: (region: NotificareRegion) => void): EmitterSubscription;
/**
* Called when the user enters the proximity of a beacon.
*
* @param callback - A callback that will be invoked with the result of the
* onBeaconEntered event. It will provide the {@link NotificareBeacon}
* representing the beacon the user has entered the proximity of.
* @returns {EmitterSubscription} - The {@link EmitterSubscription} for the
* onBeaconEntered event.
*/
static onBeaconEntered(callback: (beacon: NotificareBeacon) => void): EmitterSubscription;
/**
* Called when the user exits the proximity of a beacon.
*
* @param callback - A callback that will be invoked with the result of the
* onBeaconExited event. It will provide the {@link NotificareBeacon}
* representing the beacon the user has exited the proximity of.
* @returns {EmitterSubscription} - The {@link EmitterSubscription} for the
* onBeaconExited event.
*/
static onBeaconExited(callback: (beacon: NotificareBeacon) => void): EmitterSubscription;
/**
* Called when beacons are ranged in a monitored region.
*
* This method provides the list of beacons currently detected within the given
* region.
*
* @param callback - A callback that will be invoked with the result of the
* onBeaconsRanged event. It will provide a list of {@link NotificareBeacon}
* that were detected and the {@link NotificareRegion} where they were detected.
* @returns {EmitterSubscription} - The {@link EmitterSubscription} for the
* onBeaconsRanged event.
*/
static onBeaconsRanged(callback: (data: {
region: NotificareRegion;
beacons: NotificareBeacon[];
}) => void): EmitterSubscription;
/**
* Called when the device registers a location visit.
*
* **Note**: This method is only supported on iOS.
*
* @param callback - A callback that will be invoked with the result of the
* onVisit event. It will provide a {@link NotificareVisit} object representing
* the details of the visit.
* @returns {EmitterSubscription} - The {@link EmitterSubscription} for the
* onVisit event.
*/
static onVisit(callback: (visit: NotificareVisit) => void): EmitterSubscription;
/**
* Called when there is an update to the device’s heading.
*
* **Note**: This method is only supported on iOS.
*
* @param callback - A callback that will be invoked with the result of the
* onHeadingUpdated event. It will provide a {@link NotificareHeading} object
* containing the details of the updated heading.
* @returns {EmitterSubscription} - The {@link EmitterSubscription} for the
* onHeadingUpdated event.
*/
static onHeadingUpdated(callback: (heading: NotificareHeading) => void): EmitterSubscription;
}
//# sourceMappingURL=notificare-geo.d.ts.map