$ npm install git+https://[email protected]:transistorsoft/react-native-background-geolocation-android.git --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 Phases
thenLink Binary With Libraries
. Add the following 2 static libraries: -
Add the following Cocoa framework dependency to your target's
Link Binary With Libraries
build 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-android/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-android/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
RNBackgroundFetch
project and drag/drop the fileRNBackgroundFetch+AppDelegate.m
and place the file to exist in the same folder as your app'sAppDelegate.m
.
You can now import and build.