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

    Interface State

    Effective runtime state returned by BackgroundGeolocation.ready/getState.

    State is the active Config (compound), plus runtime-only fields.

    interface State {
        enabled: boolean;
        isMoving: boolean;
        schedulerEnabled: boolean;
        trackingMode: TrackingMode;
        odometer: number;
        odometerError: number;
        didLaunchInBackground: boolean;
        didDeviceReboot: boolean;
        reset?: boolean;
        logger?: LoggerConfig;
        geolocation?: GeoConfig;
        http?: HttpConfig;
        app?: AppConfig;
        persistence?: PersistenceConfig;
        activity?: ActivityConfig;
        authorization?: AuthorizationConfig;
        transistorAuthorizationToken?: TransistorAuthorizationToken;
    }

    Hierarchy (View Summary)

    Index

    Properties

    enabled: boolean

    Whether the SDK has been enabled via start or startGeofences.

    isMoving: boolean

    Whether the SDK is currently in the moving state (vs stationary).

    // If the SDK is currently in the *stationary* state, with State.isMoving == false:

    BackgroundGeolocation.onMotionChange((isMoving) => {
    console.log('[onMotionChange] isMoving?', isMoving);
    });

    await BackgroundGeolocation.changePace(true);
    // State.isMoving is now true.
    schedulerEnabled: boolean

    true when a schedule is configured and startSchedule() executed. stopSchedule() will set this to false.

    trackingMode: TrackingMode

    Tracking mode.

    Value Name Description
    0 Geofences Monitor geofences only.
    1 Location Monitor location + geofences.
    await BackgroundGeolocation.start();

    const state = await BackgroundGeolocation.getState();
    console.log('Tracking mode:', state.trackingMode);
    > 'Tracking mode: 1'

    await BackgroundGeolocation.startGeofences();
    console.log('Tracking mode:', state.trackingMode);
    > 'Tracking mode: 0'
    odometer: number
    odometerError: number

    The accumulated error in the odometer (in meters).

    didLaunchInBackground: boolean

    iOS only. true when the app was launched in the background due to a background event (fetch, geofence exit, stationary geofence exit). Always false on Android.

    didDeviceReboot: boolean

    Indicates if the app was launched after a device reboot.

    reset?: boolean

    Reset the plugin to its initial state before applying this configuration. This is probably what you want.

    Defaults to true

    If you set this to false, the SDK will consume your Config only at the first install of your app. Thereafter, the only way to change your configuration will be to call BackgroundGeolocation.setConfig,

    You will certainly NOT want to use reset: false during development, as it will prevent your configuration changes from taking effect on subsequent app launches.

    logger?: LoggerConfig

    Logger configuration.

    geolocation?: GeoConfig

    Geolocation configuration.

    http?: HttpConfig

    HTTP configuration.

    app?: AppConfig

    App configuration.

    persistence?: PersistenceConfig

    Persistence configuration.

    activity?: ActivityConfig

    Motion Activity configuration.

    authorization?: AuthorizationConfig

    Authorization configuration.

    transistorAuthorizationToken?: TransistorAuthorizationToken

    Convenience option to automatically configures the SDK to upload locations to the Transistor Software demo server at http://tracker.transistorsoft.com (or your own local instance of background-geolocation-console)

    See TransistorAuthorizationService. This option will automatically configure the HttpConfig.url to point at the Demo server as well as well as the required AuthorizationConfig configuration.

    const token = await
    BackgroundGeolocation.findOrCreateTransistorAuthorizationToken("my-company-name", "my-username");

    BackgroundGeolocation.ready({
    transistorAuthorizationToken: token
    });

    This convenience option merely performs the following [[Authorization]] configuration automatically for you:

    // Base url to Transistor Demo Server.
    const url = "http://tracker.transistorsoft.com";

    // Register for an authorization token from server.
    const token = await
    BackgroundGeolocation.findOrCreateTransistorAuthorizationToken("my-company-name", "my-username");

    BackgroundGeolocation.ready({
    url: url + "/api/locations",
    authorization: {
    strategy: "JWT",
    accessToken: token.accessToken,
    refreshToken: token.refreshToken,
    refreshUrl: url + "/v2/refresh_token",
    refreshPayload: {
    refresh_token: "{refreshToken}"
    },
    expires: token.expires
    }
    });