Skip to content

Latest commit

 

History

History
88 lines (62 loc) · 4.96 KB

INSTALL-IOS.md

File metadata and controls

88 lines (62 loc) · 4.96 KB

iOS Manual Installation

$ 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:

    • node_modules/react-native-background-geolocation-android/ios/RNBackgroundGeolocation.xcodeproj
  • Add 2nd of 3 Libraries:

    • node_modules/react-native-background-fetch/ios/RNBackgroundFetch.xcodeproj
  • Add a 3rd of 3 Libraries:

    • node_modules/cocoa-lumberjack/CocoaLumberjack/Lumberjack.xcodeproj

Build Phases ➜ Link Binary With Libraries

  • Select your project in the Project navigator. Click Build Phases then Link Binary With Libraries. Add the following 2 static libraries:

    • libRNBackgroundGeolocation.a
    • libRNBackgroundFetch.a.
    • libCocoaLumberjack.a
  • Add the following Cocoa framework dependency to your target's Link Binary With Libraries build phase:

    • libsqlite3.tbd
    • libz.tbd
  • 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.

  • Add another framework, same process as previous:
    • Click [Add Other...].
    • Navigate: node_modules/react-native-background-fetch/ios/RNBackgroundFetch
    • Add TSBackgroundFetch.framework.

Build Settings ➜ Framework Search Paths

  • 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

Configure Background Capabilities

  • 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 AppDelegate extension

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 file RNBackgroundFetch+AppDelegate.m and place the file to exist in the same folder as your app's AppDelegate.m.

You can now import and build.