Skip to content

Latest commit

 

History

History
94 lines (62 loc) · 4 KB

INSTALL-IOS.md

File metadata and controls

94 lines (62 loc) · 4 KB

iOS Installation

You will have to install the plugin by manually downloading a Release from this repository. The plugin is not currently submitted to a package manager (eg: jCenter)

Create a folder in the root of your application project, eg: /Libraries and place the extracted background-geolocation folder into it:

eg: 📂 Libraries/background-geolocation-lt

Install CocoaLumberjack

BackgroundGeolocation uses CocoaLumberjack for logging. Install it now:

A. Cocoapods Installation

pod 'CocoaLumberjack'

B. Carthage

github "CocoaLumberjack/CocoaLumberjack"

C. Manual

  1. Right click on your Project root ➜ New Group: "Libraries"

  2. Download latest release of CocaoLumberjack. Extract to  :open_file_folder:Libraries folder you just created.

  3. Right click  :open_file_folder:Libraries ➜ Add file to <...>. Add Lumberjack.xcodeproj:

  4. Build Phases Link Binary With Libraries ➜ Add libCocoaLumberjack.a

Install Background Geolocation SDKs

Install the following two Cocoa Frameworks:

  • TSLocationManager.framework
  • TSBackgroundFetch.framework

Right-click  :open_file_folder:FrameworksAdd Files to...

  • Browse to Libraries/background-geolocation-lt/ios/BackgroundGeolocation

Build Phases ➜ Link Binary With Libraries

  • Add the following Cocoa framework dependencies to your target's Link Binary With Libraries build phase:
    • libsqlite3.tbd
    • libz.tbd

Configure Background Capabilities

With YourApp.xcworkspace open in XCode, add the following Background Modes Capabilities:

  • Location updates
  • Background fetch
  • Audio (optional for debug-mode sound FX)

Info.plist

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

Background Fetch API

The Background Geolocation SDK is integrated with the iOS Background Fetch API.

In Your AppDelegate.h, add the following block:

@import TSBackgroundFetch;

-(void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
    TSBackgroundFetch *fetchManager = [TSBackgroundFetch sharedInstance];
    [fetchManager performFetchWithCompletionHandler:completionHandler applicationState:application.applicationState];
}

You can now import and build.