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)
Add the following pod
to your Podfile
, providing the path to where you installed the background-geolocation-lt
SDK:
pod 'BackgroundGeolocation', :path => '../Libraries/background-geolocation-lt/ios/BackgroundGeolocation.podspec'
$ pod install
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];
}