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
BackgroundGeolocation
uses CocoaLumberjack
for logging. Install it now:
pod 'CocoaLumberjack'
github "CocoaLumberjack/CocoaLumberjack"
-
Download latest release of
CocaoLumberjack
. Extract to :open_file_folder:Libraries folder you just created. -
Right click :open_file_folder:Libraries ➜ Add file to <...>. Add
Lumberjack.xcodeproj
: -
Build Phases Link Binary With Libraries ➜ Add
libCocoaLumberjack.a
Install the following two Cocoa Frameworks:
TSLocationManager.framework
TSBackgroundFetch.framework
Right-click :open_file_folder:Frameworks ➜ Add Files to...
- Add the following Cocoa framework dependencies to your target's
Link Binary With Libraries
build phase:libsqlite3.tbd
libz.tbd
With YourApp.xcworkspace
open in XCode, add the following Background Modes Capabilities:
- 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 |
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.