To install the @mauron85/react-native-background-geolocation package for React Native, follow these steps:

  1. Install the Package: Open your terminal or command prompt, navigate to your React Native project's root directory, and run the following command:

    Using npm:

    npm install @mauron85/react-native-background-geolocation --save

    Using Yarn:

    yarn add @mauron85/react-native-background-geolocation
  2. Link the Package (for React Native < 0.60): If your React Native version is less than 0.60, you need to link the package manually. In React Native 0.60 and above, auto-linking is supported.

    Using React Native CLI:

    react-native link @mauron85/react-native-background-geolocation

    If you are using React Native 0.60 and above, you can skip this step as auto-linking will take care of it.

  3. Configure the Package: The react-native-background-geolocation package requires some configuration steps for both Android and iOS platforms. Follow the configuration guide provided by the package documentation:

  4. Use the Package: After installation and configuration, you can use the package in your React Native application. Import the package where you need to use it and start using its APIs.

    For example:

    import BackgroundGeolocation from '@mauron85/react-native-background-geolocation'; // Start tracking location BackgroundGeolocation.configure({ desiredAccuracy: BackgroundGeolocation.HIGH_ACCURACY, stationaryRadius: 50, distanceFilter: 50, notificationTitle: 'Background tracking', notificationText: 'enabled', debug: true, startOnBoot: false, stopOnTerminate: true, locationProvider: BackgroundGeolocation.ACTIVITY_PROVIDER, interval: 10000, fastestInterval: 5000, activitiesInterval: 10000, stopOnStillActivity: false, }); BackgroundGeolocation.on('location', (location) => { console.log('Location:', location); }); BackgroundGeolocation.start();

Please note that the usage example above may vary based on your specific requirements and the configuration options you've set during setup. Refer to the package documentation for a complete list of configuration options and API methods available in @mauron85/react-native-background-geolocation.

Have questions or queries?
Get in Touch