Skip to content

Latest commit

 

History

History
58 lines (37 loc) · 1.54 KB

INSTALL_CAPACITOR.md

File metadata and controls

58 lines (37 loc) · 1.54 KB

Capacitor Setup

npm install cordova-plugin-background-fetch
npx cap sync

iOS Setup

Configure Background Capabilities

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

  • Background fetch

AppDelegate.swift

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

In Your AppDelegate.swift, add the following code (just the +green lines):

import UIKit
import Capacitor
+import TSBackgroundFetch

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

  var window: UIWindow?

  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
    return true
  }

+ //Added for cordova-plugin-background-fetch
+ func application(_ application: UIApplication, performFetchWithCompletionHandler completionHandler:@escaping (UIBackgroundFetchResult) -> Void) {
+   NSLog("AppDelegate received fetch event");
+   let fetchManager = TSBackgroundFetch.sharedInstance();
+   fetchManager?.perform(completionHandler: completionHandler, applicationState: application.applicationState);
+ }
  .
  .
  .
}

Android Setup

Nothing else to perform