Skip to content

Latest commit

 

History

History
69 lines (45 loc) · 2.54 KB

INSTALL-COCOAPODS-IOS.md

File metadata and controls

69 lines (45 loc) · 2.54 KB

iOS Installation with CocoaPods

$ 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 that platform :ios, '8.0' is set to 8.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

XCode Configuration

  • Open your App.xcworkspace

Configure Background Capabilities

  • Select the root of your project. Select Capabilities tab. Enable Background Modes and enable the following modes:

  • Background fetch

BackgroundFetch AppDelegate extension

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.

  • Add the file RNBackgroundFetch+AppDelegate.m:

Troubleshooting with CocoaPods

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'
```#