UNPKG

react-native-background-geolocation

Version:

The most sophisticated cross-platform background location-tracking & geofencing module with battery-conscious motion-detection intelligence

50 lines (46 loc) â€ĸ 1.59 kB
/// <reference path="../types.d.ts" /> declare module "react-native-background-geolocation" { /** * This is the event-object provided to Android headless-tasks registered via [[BackgroundGeolocation.registerHeadlessTask]]. * * @example * ```typescript * const BackgroundGeolocationHeadlessTask = async (event) => { * const params = event.params; * console.log("[BackgroundGeolocation HeadlessTask] -", event.name, params); * * switch (event.name) { * case "terminate": * // Use await for async tasks * const location = await BackgroundGeolocation.getCurrentPosition({ * samples: 1, * persist: false * }); * console.log("[BackgroundGeolocation HeadlessTask] - getCurrentPosition:", location); * break; * } * // You must await all work you do in your task. * // Headless-tasks are automatically terminated after executing the last line of your function. * await doWork(); * } * * BackgroundGeolocation.registerHeadlessTask(BackgroundGeolocationHeadlessTask); * ``` * * ### â„šī¸ See also: * - 📘 [Android Headless Mode](github:wiki/Android-Headless-Mode). * - [[BackgroundGeolocation.registerHeadlessTask]] * - [[Config.enableHeadless]] * */ interface HeadlessEvent { /** * BackgroundGeolocation event name (eg: `location`, `motionchange`, `terminate`, `http`, etc). */ name: Event; /** * General event params according to the context of the event name. */ params: Map; } }