transistorsoft / nativescript-background-fetch

iOS Background Fetch API Implementation for NativeScript
Other
28 stars 9 forks source link

Refactor plugin. #4

Closed christocracy closed 7 years ago

christocracy commented 7 years ago

[1.1.0]

Note This version requires a breaking change to the AppDelegate definition (See the README

app.ts

import * as app from 'application';

+import {BackgroundFetch} from "nativescript-background-fetch";

+if (app.ios) {
+  class MyDelegate extends UIResponder implements UIApplicationDelegate {
+    public static ObjCProtocols = [UIApplicationDelegate];

+    public applicationPerformFetchWithCompletionHandler(application: UIApplication, completionHandler:any) {
+      BackgroundFetch.performFetchWithCompletionHandler(application, completionHandler);
+    }
+  }
+  app.ios.delegate = MyDelegate;
+}

app.start({ moduleName: 'main-page' });