$ npm install react-native-background-geolocation --save
-
In the XCode's
Project navigator, right click on project's name ➜Add Files to <...> -
Add 1st of 3 Libraries:
-
Add 2nd of 3 Libraries:
-
Add a 3rd of 3 Libraries:
-
Select your project in the
Project navigator. ClickBuild PhasesthenLink Binary With Libraries. Add the following 2 static libraries: -
Add the following Cocoa framework dependency to your target's
Link Binary With Librariesbuild phase: -
BackgroundGeolocation includes a couple of custom iOS frameworks. These need to manually added, unfortunately.
- Click
[Add Other...]. - Navigate:
node_modules/react-native-background-geolocation/ios/RNBackgroundGeolocation. - Add
TSLocationManager.framework.
- Click
- Add another framework, same process as previous:
- In order to the find the Frameworks you just added, you have to tell Xcode where it can find them:
- Go to Build Settings and search for "framework search path".
- Add the following paths (select recursive [v]):
$(PROJECT_DIR)/../node_modules/react-native-background-geolocation/ios
$(PROJECT_DIR)/../node_modules/react-native-background-fetch/ios
-
Select the root of your project. Select Capabilities tab. Enable Background Modes and enable the following modes:
-
Location updates
-
Background fetch
-
Audio (optional for debug-mode sound FX)
- Edit
Info.plist. Add the following items (Set Value as desired):
| Key | Value | Description |
|---|---|---|
| NSLocationAlwaysUsageDescription | This app requires background tracking | Deprecated in iOS 11 The value here will be presented to the user when the plugin requests Background Location permission |
| NSLocationAlwaysAndWhenInUseUsageDescription | This app requires background tracking | New for iOS 11 The value here will be presented to the user when the plugin requests Background Location permission |
| NSMotionUsageDescription | Accelerometer use increases battery efficiency by intelligently toggling location-tracking | The value here will be presented to the user when the app requests Motion Activity permission. |
BackgroundFetch implements an AppDelegate method didPerformFetchWithCompletionHandler. You must manually add this file to the same folder where your AppDelegate.m lives:
- Expand the
RNBackgroundFetchproject and drag/drop the fileRNBackgroundFetch+AppDelegate.mand place the file to exist in the same folder as your app'sAppDelegate.m.
You can now import and build.











