$ npm install --save react-native-background-fetch
If you use already CocoaPods in your react-native project, you can also add the react-native-mapbox-gl project to your Podfile.
NOTE The path to node_modules
depends on your Podfile location, whether in {root}
of the react-native project (node_modules
) or {root}/ios
(../node_modules
). The following instructions assume {root}/ios
- In your
Podfile
, make sure thatplatform :ios, '8.0'
is set to8.0
- Add the following Pod (Including
React
if it's not already there)
platform :ios, '8.0'
pod 'React', :path => '../node_modules/react-native'
pod 'RNBackgroundFetch', :path => '../node_modules/react-native-background-fetch'
- Install the new CocoaPods dependency with:
$ pod install
- Open your
App.xcworkspace
-
Select the root of your project. Select Capabilities tab. Enable Background Modes and enable the following modes:
-
Background fetch
BackgroundFetch implements an AppDelegate
method didPerformFetchWithCompletionHandler
. You must manually add this file to the same folder where your AppDelegate.m
lives:
-
Right click your app's root folder. Select
Add files to...
. Select Other. -
Browse to
{YourApp}/node_modules/react-native-background-fetch/ios/RNBackgroundFetch
.
Because react-native is only available as npm module (and not as "regular" CocoaPods dependency, see v0.13 release notes for more informations).
So it is required that you import react-native also from a local path.
Ensure that you include React
before you include react-native-background-fetch
in
your Podfile
. Here is a complete working example if you want add your Podfile
in the project root while your generated Xcode project is still in the ios
folder:
platform :ios, '8.0'
pod 'React', :path => '../node_modules/react-native'
pod 'RNBackgroundFetch', :path => '../node_modules/react-native-background-fetch'
```#