Skip to content
react native library that uses the iOS Significant-Change Location Service
C# Objective-C Java Ruby JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
android change package Mar 21, 2017
ios Update docs for iOS 11+, remove comments Jun 21, 2019
windows
.gitignore added ignore Mar 14, 2017
README.md Update docs for iOS 11+, remove comments Jun 21, 2019
index.js initial commit Mar 14, 2017
package.json clean up Apr 5, 2017

README.md

react-native-location-change

React native library for providing low-power, background geographic location changes.

Not supported on Android yet.

On iOS it uses the significant-change location service . It can supply location updates in the background without having to use the Location Updates background mode [view apple docs].

Getting started

Add the dependency (its not on npm yet)

npm install react-native-location-change@https://github.com/npomfret/react-native-location-change.git --save
react-native link react-native-location-change

iOS installation

Standard RN installation instructions for a native module are below, but you also need to modify your info.plist file:

iOS 11 and higher: NSLocationAlwaysAndWhenInUseUsageDescription This is needed to get location updates NSLocationAlwaysUsageDescription This is needed to get location updates in the background

Prior to iOS 11: NSLocationAlwaysAndWhenInUseUsageDescription This is needed to get location updates NSLocationAlwaysUsageDescription This is needed to get location updates in the background

If you'd like background updates, you may also need to add the following UI background modes to youy info.plist file:

<key>UIBackgroundModes</key>
<array>
	<string>fetch</string>
	<string>location</string>
</array>

Usage

import {AppRegistry, StyleSheet, Text, View, NativeModules, NativeEventEmitter} from "react-native";

const _EVENT_EMITTER = new NativeEventEmitter(NativeModules.RNLocationChange);

export default class LocationChangeExample extends Component {
  componentWillMount() {
    this.setState({location: null});

    _EVENT_EMITTER.addListener('significantLocationChange', (data) => {
      console.log("event:", data);
      this.setState({location: data});
    });

    NativeModules.RNLocationChange.start();
  }

  componentWillUnmount() {
    NativeModules.RNLocationChange.stop();
  }

An working example is here.

You can’t perform that action at this time.