react-native-background-geolocation@5.0.0-beta.1
    Preparing search index...

    Interface Subscription

    // Event-listeners return a Subscription instance, containing a .remove() method.
    const subscription = BackgroundGeolocation.onLocation(location => {
    console.log("[onLocation] ", location);
    });
    .
    .
    .
    // Later, to remove the event-listener:
    subscription.remove();

    One might typically manage a collection of Subscription instances

    import BackgroundGeolocation, {
    Location,
    Subscription
    } from ...

    // Your custom Collection of Subscription instances.
    const SUBSCRIPTIONS = [];

    // Your custom method to push a Subscription instance.
    const subscribe = (subscription:Subscription) => {
    SUBSCRIPTIONS.push(subscription);
    }

    // Your custom method to interate your SUBSCRIPTIONS and .remove each.
    const unsubscribe = () => {
    SUBSCRIPTIONS.forEach((subscription:Subscription) => subscription.remove());
    }

    const initBackgroundGeolocation = () {
    // Create event-listeners as usual, feeding the returned Subscription into
    // your custom subscribe() method.
    subscribe(BackgroundGeolocation.onLocation((location:Location) => {
    console.log('[onLocation]', location);
    });

    subscribe(BackgroundGeolocation.onMotionChange((location:Location) => {
    console.log('[onMotionChange]', location);
    });

    subscribe(BackgroundGeolocation.onEnabledChange((enabled:boolean) => {
    console.log('[onEnabledChange]', enabled);
    });
    }

    const onDestroyView = () => {
    // Call your custom unsubscribe method
    unsubscribe();
    }
    interface Subscription {
        remove(): void;
    }
    Index

    Methods

    Methods

    • Remove the event-listener.

      Returns void