yarn add https://github.com/transistorsoft/react-native-background-geolocation-android.git
yarn add react-native-background-fetch
npm install https://github.com/transistorsoft/react-native-background-geolocation-android.git --save
npm install react-native-background-fetch --save
$ cd ios
$ pod install
Open your App in XCode and 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 | Type | Value |
---|---|---|
Privacy - Location Always and When in Use Usage Description | String |
CHANGEME: Location required in background |
Privacy - Location When in Use Usage Description | String |
CHANGEME: Location required when app is in use |
Privacy - Motion Usage Description | String |
CHANGEME: Motion permission helps detect when device in in-motion |
BackgroundFetch implements an AppDelegate
method didPerformFetchWithCompletionHandler
. You must manually add this file to the same folder where your AppDelegate.m
lives:
- In the XCode's
Project navigator
, right click on project's name ➜Add Files to <...>
. node_modules/react-native-background-fetch/ios/RNBackgroundFetch/RNBackgroundFetch+AppDelegate.m
.
node_modules/react-native-background-fetch/ios/RNBackgroundFetch/RNBackgroundFetch+AppDelegate.m