Skip to content

Releases: timfpark/react-native-location

v2.2.1

03 Jun 02:09
Compare
Choose a tag to compare

Fixes an issue on Android where we were using the Activity when it was null. Details here:

v2.2.0

24 Feb 16:02
Compare
Choose a tag to compare

Features

Added additional configuration options for Android (interval, fastestInterval, and maxWaitTime). Thanks to @[naftalibeder for reporting these as missing. As an example, you can use them to get updates every 1 second:

RNLocation.configure({
  desiredAccuracy: {
    ios: "best",
    android: "highAccuracy"
  },
  interval: 1000,
  maxWaitTime: 1000
});

v2.1.1

06 Feb 11:38
Compare
Choose a tag to compare

Bug fixes

  • Babel issues with older versions of React Native due to .bablerc being distributed via npm

v2.1.0

06 Feb 11:39
Compare
Choose a tag to compare

New Features

RNLocation.getLatestLocation

Get the latest location. Ensure you have the correct permission before calling this method.

This will subscribe to location events for you at the unsubscribe when it gets its first valid location. Usually, this method will return very fast with a possibly out of date location, however, in some circumstances, it will not return a location. Therefore, this method has a timeout after which the promise will be resolved with null value.

The location provider will respect the settings you have given it, so if you need a location with a certain accuracy, ensure you call RNLocation.configure first. If you want any location then ensure you call RNLocation.configure with no distance filter.

RNLocation.configure({ distanceFilter: null });
RNLocation.getLatestLocation({ timeout: 60000 })
  .then(latestLocation => {
    // Use the location here
  })

v2.0.2

05 Feb 09:19
Compare
Choose a tag to compare

Bug Fixes

  • Fix an Android crash by using a lower request code when attempting to resolve Google Play Service errors.

v2.0.1

21 Jan 11:36
Compare
Choose a tag to compare
  • [Fix] Add the required package.json properties to allow installing with Cocoapods to work

v2.0.0

19 Jan 11:29
Compare
Choose a tag to compare

Changes

  • Support for Android using the Fused Location provider.
  • New API which allows for more flexibility in the future without further breaking changes.
  • Ability to filter heading updates in the same way as locations.
  • Returns all locations to the listener, not just the latest one which can be useful for some applications.
  • Add Cocoapods support for iOS.
  • Improved test coverage.

Upgrading

Configuring

Configuring the settings for location updates now happens in a single method. You supply an object with the desired values and the location provider is then configured. This allows multiple settings to be changed at once without going back and forth over the bridge.

For example, this code from v1.0.0:

RNLocation.setDistanceFilter(5.0);
RNLocation.setDesiredAccuracy("best");

Would become this in v2.0.0:

RNLocation.configure({
  distanceFilter: 5,
  desiredAccuracy: {
    ios: "best",
    android: "highAccuracy"
  }
});

Permissions

Requesting permissions has also been combined into a single method where you specify the desired permission levels for both Android and iOS. For example, this code from v1.0.0:

RNLocation.requestAlwaysAuthorization();

Would become this in v2.0.0:

RNLocation.requestPermission({
  ios: "always",
  // New Android support in v2.0.0
  android: "fine"
});

Location subscriptions

When subscribing to location updates, the listener is now given an array of locations rather than just the last one. This is useful for some apps which might want to know the history of the device location. The shape of the location object has also been changed to be flatter and easier to work with.

For example, this code from v1.0.0:

const locationSubscription = RNLocation.subscribeToLocationUpdates(location => {
  /* Example location returned
        {
          coords: {
            speed: -1,
            longitude: -0.1337,
            latitude: 51.50998,
            accuracy: 5,
            heading: -1,
            altitude: 0,
            altitudeAccuracy: -1
          },
          timestamp: 1446007304457.029
        }
        */
});

Becomes this in v2.0.0:

const locationSubscription = RNLocation.subscribeToLocationUpdates(locations => {
  const location = locations[0];
  /* Example location returned
        {
          speed: -1,
          longitude: -0.1337,
          latitude: 51.50998,
          accuracy: 5,
          heading: -1,
          altitude: 0,
          altitudeAccuracy: -1
          floor: 0
          timestamp: 1446007304457.029
        }
        */
});

v2.0.0 (Beta 1)

29 Dec 10:55
Compare
Choose a tag to compare
v2.0.0 (Beta 1) Pre-release
Pre-release

Changes

  • Support for Android using the Fused Location provider.
  • New API which allows for more flexibility in the future without further breaking changes.
  • Ability to filter heading updates in the same way as locations.
  • Returns all locations to the listener, not just the latest one which can be useful for some applications.
  • Improved test coverage.

Upgrading

Configuring

Configuring the settings for location updates now happens in a single method. You supply an object with the desired values and the location provider is then configured. This allows multiple settings to be changed at once without going back and forth over the bridge.

For example, this code from v1.0.0:

RNLocation.setDistanceFilter(5.0);
RNLocation.setDesiredAccuracy("best");

Would become this in v2.0.0:

RNLocation.configure({
  distanceFilter: 5,
  desiredAccuracy: {
    ios: "best",
    android: "highAccuracy"
  }
});

Permissions

Requesting permissions has also been combined into a single method where you specify the desired permission levels for both Android and iOS. For example, this code from v1.0.0:

RNLocation.requestAlwaysAuthorization();

Would become this in v2.0.0:

RNLocation.requestPermission({
  ios: "always",
  // New Android support in v2.0.0
  android: "fine"
});

Location subscriptions

When subscribing to location updates, the listener is now given an array of locations rather than just the last one. This is useful for some apps which might want to know the history of the device location. The shape of the location object has also been changed to be flatter and easier to work with.

For example, this code from v1.0.0:

const locationSubscription = RNLocation.subscribeToLocationUpdates(location => {
  /* Example location returned
        {
          coords: {
            speed: -1,
            longitude: -0.1337,
            latitude: 51.50998,
            accuracy: 5,
            heading: -1,
            altitude: 0,
            altitudeAccuracy: -1
          },
          timestamp: 1446007304457.029
        }
        */
});

Becomes this in v2.0.0:

const locationSubscription = RNLocation.subscribeToLocationUpdates(locations => {
  const location = locations[0];
  /* Example location returned
        {
          speed: -1,
          longitude: -0.1337,
          latitude: 51.50998,
          accuracy: 5,
          heading: -1,
          altitude: 0,
          altitudeAccuracy: -1
          floor: 0
          timestamp: 1446007304457.029
        }
        */
});

v1.0.0

17 Nov 17:34
Compare
Choose a tag to compare

Changes

  • Support newer versions of React Native. It should support from React Native 0.46 and above, however, it is recommended to use the latest React Native version (0.57.5 when this was published).
  • Added types to the library. These should work with both Flow and TypeScript.
  • Update the library to use the NativeEventEmitter. See the upgrade guide below.
  • Updated the README with better installation instructions and a rationale for using the library.

Upgrading

The API for listening to events has been changed. You now need to import the RNLocationEventEmitter from the library and then call addListener on that object.

For example:

import RNLocation, { RNLocationEventEmitter } from 'react-native-location';

RNLocation.requestAlwaysAuthorization();
RNLocation.startUpdatingLocation();
RNLocation.setDistanceFilter(5.0);

var subscription = RNLocationEventEmitter.addListener('locationUpdated', (location) => {
    // TODO: Implement
});