├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── demo ├── app │ ├── App_Resources │ │ ├── Android │ │ │ ├── app.gradle │ │ │ └── src │ │ │ │ └── main │ │ │ │ ├── AndroidManifest.xml │ │ │ │ └── res │ │ │ │ ├── drawable-hdpi │ │ │ │ ├── background.png │ │ │ │ ├── icon.png │ │ │ │ └── logo.png │ │ │ │ ├── drawable-ldpi │ │ │ │ ├── background.png │ │ │ │ ├── icon.png │ │ │ │ └── logo.png │ │ │ │ ├── drawable-mdpi │ │ │ │ ├── background.png │ │ │ │ ├── icon.png │ │ │ │ └── logo.png │ │ │ │ ├── drawable-nodpi │ │ │ │ └── splash_screen.xml │ │ │ │ ├── drawable-xhdpi │ │ │ │ ├── background.png │ │ │ │ ├── icon.png │ │ │ │ └── logo.png │ │ │ │ ├── drawable-xxhdpi │ │ │ │ ├── background.png │ │ │ │ ├── icon.png │ │ │ │ └── logo.png │ │ │ │ ├── drawable-xxxhdpi │ │ │ │ ├── background.png │ │ │ │ ├── icon.png │ │ │ │ └── logo.png │ │ │ │ ├── values-v21 │ │ │ │ ├── colors.xml │ │ │ │ └── styles.xml │ │ │ │ └── values │ │ │ │ ├── colors.xml │ │ │ │ └── styles.xml │ │ └── iOS │ │ │ ├── Assets.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ ├── Contents.json │ │ │ │ ├── icon-29.png │ │ │ │ ├── icon-29@2x.png │ │ │ │ ├── icon-29@3x.png │ │ │ │ ├── icon-40.png │ │ │ │ ├── icon-40@2x.png │ │ │ │ ├── icon-40@3x.png │ │ │ │ ├── icon-50.png │ │ │ │ ├── icon-50@2x.png │ │ │ │ ├── icon-57.png │ │ │ │ ├── icon-57@2x.png │ │ │ │ ├── icon-60@2x.png │ │ │ │ ├── icon-60@3x.png │ │ │ │ ├── icon-72.png │ │ │ │ ├── icon-72@2x.png │ │ │ │ ├── icon-76.png │ │ │ │ ├── icon-76@2x.png │ │ │ │ └── icon-83.5@2x.png │ │ │ ├── Contents.json │ │ │ ├── LaunchImage.launchimage │ │ │ │ ├── Contents.json │ │ │ │ ├── Default-568h@2x.png │ │ │ │ ├── Default-667h@2x.png │ │ │ │ ├── Default-736h@3x.png │ │ │ │ ├── Default-Landscape.png │ │ │ │ ├── Default-Landscape@2x.png │ │ │ │ ├── Default-Landscape@3x.png │ │ │ │ ├── Default-Portrait.png │ │ │ │ ├── Default-Portrait@2x.png │ │ │ │ ├── Default.png │ │ │ │ └── Default@2x.png │ │ │ ├── LaunchScreen.AspectFill.imageset │ │ │ │ ├── Contents.json │ │ │ │ ├── LaunchScreen-AspectFill.png │ │ │ │ └── LaunchScreen-AspectFill@2x.png │ │ │ └── LaunchScreen.Center.imageset │ │ │ │ ├── Contents.json │ │ │ │ ├── LaunchScreen-Center.png │ │ │ │ └── LaunchScreen-Center@2x.png │ │ │ ├── Info.plist │ │ │ ├── LaunchScreen.storyboard │ │ │ └── build.xcconfig │ ├── app-root.xml │ ├── app.css │ ├── app.ts │ ├── bundle-config.ts │ ├── main-page.ts │ ├── main-page.xml │ ├── main-view-model.ts │ └── package.json ├── package.json ├── references.d.ts └── tsconfig.json └── src ├── .npmignore ├── HeadlessBroadcastReceiver.android.d.ts ├── HeadlessBroadcastReceiver.android.ts ├── HeadlessJobService.android.d.ts ├── HeadlessJobService.android.ts ├── background-fetch.android.d.ts ├── background-fetch.android.ts ├── background-fetch.d.ts ├── background-fetch.ios.d.ts ├── background-fetch.ios.ts ├── common.d.ts ├── common.ts ├── headless-task.d.ts ├── headless-task.ts ├── package.json ├── platforms ├── android │ ├── AndroidManifest.xml │ ├── include.gradle │ └── libs │ │ └── tsbackgroundfetch.aar └── ios │ ├── Info.plist │ ├── Podfile │ ├── TSBackgroundFetch.framework │ ├── Headers │ │ └── TSBackgroundFetch.h │ ├── Info.plist │ ├── Modules │ │ └── module.modulemap │ ├── TSBackgroundFetch │ └── _CodeSignature │ │ ├── CodeDirectory │ │ ├── CodeRequirements │ │ ├── CodeRequirements-1 │ │ ├── CodeResources │ │ └── CodeSignature │ └── nativescript-background-fetch.podspec ├── references.d.ts └── tsconfig.json /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | *.js 3 | *.js.map 4 | *.log 5 | package-lock.json 6 | demo/app/*.js 7 | demo/platforms 8 | demo/node_modules 9 | demo/package-lock.json 10 | demo/lib 11 | node_modules 12 | .DS_Store 13 | 14 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # CHANGELOG 2 | 3 | ## [1.2.0] — 2018-06-18 4 | - [Added] Android implementation using `JobScheduler` / `AlarmManager` 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | nativescript-background-fetch 4 | Copyright (c) 2016, Transistor Software 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | this software and associated documentation files (the "Software"), to deal in 8 | the Software without restriction, including without limitation the rights to 9 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | the Software, and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | nativescript-background-fetch · [![npm](https://img.shields.io/npm/dm/nativescript-background-fetch.svg)]() [![npm](https://img.shields.io/npm/v/nativescript-background-fetch.svg)]() 2 | ============================================================================== 3 | 4 | [![](https://dl.dropboxusercontent.com/s/nm4s5ltlug63vv8/logo-150-print.png?dl=1)](https://www.transistorsoft.com) 5 | 6 | By [**Transistor Software**](http://transistorsoft.com), creators of [**NativeScript Background Geolocation**](http://www.transistorsoft.com/shop/products/nativescript-background-geolocation-lt) 7 | 8 | ------------------------------------------------------------------------------ 9 | 10 | Background Fetch is a *very* simple plugin which will awaken an app in the background about **every 15 minutes**, providing a short period of background running-time. This plugin will execute your provided `callbackFn` whenever a background-fetch event occurs. 11 | 12 | There is **no way** to increase the rate which a fetch-event occurs and this plugin sets the rate to the most frequent possible — you will **never** receive an event faster than **15 minutes**. The operating-system will automatically throttle the rate the background-fetch events occur based upon usage patterns. Eg: if user hasn't turned on their phone for a long period of time, fetch events will occur less frequently. 13 | 14 | The Android plugin provides a "Headless"]() implementation allowing you to continue handling events with Javascript even after app-termination (see **[`@config enableHeadless`](#config-boolean-enableheadless-false)**) 15 | 16 | ## Installing the plugin ## 17 | 18 | ```Bash 19 | $ tns plugin add nativescript-background-fetch 20 | ``` 21 | 22 | ## Setup 23 | 24 | BackgroundFetch requires implementation of the **`AppDelegate`** method **`applicationPerformFetchWithCompletionHandler`**. In your **`app.ts`**, add the following block (If you've already implemented an **`AppDelegate`**, simply add the method `applicationPerformFetchWithCompletionHandler` to your existing implementation). 25 | 26 | **`app.ts`** 27 | ```diff 28 | import * as app from 'application'; 29 | 30 | +import {BackgroundFetch} from "nativescript-background-fetch"; 31 | 32 | +if (app.ios) { 33 | + class MyDelegate extends UIResponder implements UIApplicationDelegate { 34 | + public static ObjCProtocols = [UIApplicationDelegate]; 35 | 36 | + public applicationPerformFetchWithCompletionHandler(application: UIApplication, completionHandler:any) { 37 | + BackgroundFetch.performFetchWithCompletionHandler(completionHandler, application.applicationState); 38 | + } 39 | + } 40 | + app.ios.delegate = MyDelegate; 41 | +} 42 | 43 | app.start({ moduleName: 'main-page' }); 44 | ``` 45 | 46 | **NOTE** If your build fails with the following errors: 47 | ``` 48 | app/app.ts(6,28): error TS2304: Cannot find name 'UIResponder'. 49 | app/app.ts(6,51): error TS2304: Cannot find name 'UIApplicationDelegate'. 50 | app/app.ts(7,36): error TS2304: Cannot find name 'UIApplicationDelegate'. 51 | ``` 52 | 53 | Add the following items to `references.d.ts` in the root of your project (create it if it doesn't exist): 54 | 55 | :open_file_folder: **`/references.d.ts`** 56 | ```typescript 57 | /// 58 | /// 59 | ``` 60 | 61 | ## Config 62 | 63 | ### Common Options 64 | 65 | #### `@param {Integer} minimumFetchInterval [15]` 66 | 67 | The minimum interval in **minutes** to execute background fetch events. Defaults to **`15`** minutes. **Note**: Background-fetch events will **never** occur at a frequency higher than **every 15 minutes**. Apple uses a secret algorithm to adjust the frequency of fetch events, presumably based upon usage patterns of the app. Fetch events *can* occur less often than your configured `minimumFetchInterval`. 68 | 69 | 70 | ### Android Options 71 | 72 | #### `@config {Boolean} stopOnTerminate [true]` 73 | 74 | Set `false` to continue background-fetch events after user terminates the app. Default to `true`. 75 | 76 | #### `@config {Boolean} startOnBoot [false]` 77 | 78 | Set `true` to initiate background-fetch events when the device is rebooted. Defaults to `false`. 79 | 80 | :exclamation: **NOTE:** `startOnBoot` requires `stopOnTerminate: false`. 81 | 82 | #### `@config {Boolean} forceReload [false]` 83 | 84 | Set `true` to automatically relaunch the application (if it was terminated) — the application will launch to the foreground then immediately minimize. Defaults to `false`. 85 | 86 | #### `@config {Boolean} enableHeadless [false]` 87 | 88 | Set `true` to enable the Android "Headless Javascript" mechanism, for handling fetch events **after app termination** with a Javascript callback. 89 | 90 | * :open_file_folder: **`app.ts`** 91 | ```typescript 92 | import * as application from 'application'; 93 | 94 | import {BackgroundFetch} from "nativescript-background-fetch"; 95 | 96 | if (application.android) { 97 | // This headless task will execute only when Android app is terminated. 98 | BackgroundFetch.registerHeadlessTask(async () => { 99 | console.log('[My BackgroundFetch HeadlessTask] onFetch'); 100 | // Do some asynchronous work (eg: HTTP Request) 101 | let result = await doWork(); 102 | // Politely signal to the OS that our processing is complete. 103 | BackgroundFetch.finish(); 104 | }); 105 | 106 | // Your example task. 107 | let doWork = () => { 108 | return new Promise((resolve, reject) => { 109 | // Do some work. 110 | let result = true; // <-- example result from HTTP request. 111 | if (true) { 112 | resolve('OK') 113 | } else { 114 | reject('OOPS!'); 115 | } 116 | }); 117 | } 118 | } 119 | 120 | application.run({ moduleName: 'app-root' }); 121 | ``` 122 | 123 | ## Methods 124 | 125 | | Method Name | Arguments | Notes 126 | |-------------|-----------|---------------------------------------------------| 127 | | `performFetchWithCompletionHandler` | `Function` | This method is **required** to be called in your custom `AppDelegate`, initiated the background-fetch event received from iOS. See [Setup instructions](#setup) above. | 128 | | `configure` | `{config}`, `callbackFn`, `failureFn` | Configures the plugin's fetch `callbackFn`. This callback will fire each time an iOS background-fetch event occurs (typically every 15 min). The `failureFn` will be called if the device doesn't support background-fetch. | 129 | | `status` | `callbackFn` | Your callback will be executed with the current `status (Integer)` `0: Restricted`, `1: Denied`, `2: Available`. These constants are defined as `BackgroundFetch.STATUS_RESTRICTED`, `BackgroundFetch.STATUS_DENIED`, `BackgroundFetch.STATUS_AVAILABLE` (**NOTE:** Android will always return `STATUS_AVAILABLE`)| 130 | | `finish` | `fetchResult` | Valid values for `fetchResult (Integer)` include `BackgroundFetch.FETCH_RESULT_NEW_DATA` (0), `BackgroundFetch.FETCH_RESULT_NO_DATA` (1), and `BackgroundFetch.FETCH_RESULT_FAILED` (2). You **MUST** call this method in your fetch `callbackFn` provided to `#configure` in order to signal to iOS that your fetch action is complete. iOS provides **only** 30s of background-time for a fetch-event -- if you exceed this 30s, iOS will kill your app. | 131 | | `start` | `successFn`, `failureFn` | Start the background-fetch API. Your `callbackFn` provided to `#configure` will be executed each time a background-fetch event occurs. **NOTE** the `#configure` method *automatically* calls `#start`. You do **not** have to call this method after you `#configure` the plugin | 132 | | `stop` | `successFn`, `failureFn` | Stop the background-fetch API from firing fetch events. Your `callbackFn` provided to `#configure` will no longer be executed. | 133 | | `registerHeadlessTask` | `callback` | Registers an Android "Headless Task" to receive Android background-fetch events when your application is terminated. (:warning: requires [`stopOnTerminate: false`](#config-boolean-stoponterminate-true) and [`enableHeadless: true`](#config-boolean-enableheadless-false)) | 134 | 135 | 136 | ## Example ## 137 | 138 | A full example could be: 139 | ```javascript 140 | 141 | import {BackgroundFetch} from "nativescript-background-fetch"; 142 | 143 | export class HelloWorldModel 144 | constructor() { 145 | super(); 146 | 147 | // You can query the UIBackgroundRefreshStatus. User can disable fetch. 148 | BackgroundFetch.status((status) => { 149 | console.log('- BackgroundFetch status: ', status); 150 | }); 151 | 152 | // Configure Background Fetch 153 | BackgroundFetch.configure({ 154 | stopOnTerminate: false, 155 | minimumFetchInterval: 30, // minutes 156 | stopOnTerminate: false, // Android-only 157 | startOnBoot: true // Android-only 158 | }, () => { 159 | console.log("[js] BackgroundFetch event received"); 160 | // 161 | // Do stuff. You have 30s of background-time. 162 | // 163 | // When your job is complete, you must signal completion or iOS can kill your app. Signal the nature of the fetch-event, whether you recevied: 164 | // FETCH_RESULT_NEW_DATA: Received new data from your server 165 | // FETCH_RESULT_NO_DATA: No new data received from your server 166 | // FETCH_RESULT_FAILED: Failed to receive new data. 167 | BackgroundFetch.finish(BackgroundFetch.FETCH_RESULT_NEW_DATA); 168 | }, (status) => { 169 | console.log('BackgroundFetch not supported by your OS', status); 170 | }); 171 | 172 | // Later, to stop background-fetch events from firing: 173 | //BackgroundFetch.stop(); 174 | 175 | // Or restart them again: 176 | /* 177 | BackgroundFetch.start(() => { 178 | console.log("BackgroundFetch successfully started"); 179 | }, (status) { 180 | console.log("BackgroundFetch failed to start: ", status); 181 | }); 182 | */ 183 | } 184 | } 185 | ``` 186 | 187 | ## Debugging 188 | 189 | ### iOS 190 | 191 | - Simulate background fetch events in XCode using **`Debug->Simulate Background Fetch`** 192 | - iOS can take some hours or even days to start a consistently scheduling background-fetch events since iOS schedules fetch events based upon the user's patterns of activity. If *Simulate Background Fetch* works, your can be **sure** that everything is working fine. You just need to wait. 193 | 194 | ### Android 195 | 196 | - Observe plugin logs in `$ adb logcat`: 197 | ```bash 198 | $ adb logcat *:S JS:V TSBackgroundFetch:V 199 | ``` 200 | - Simulate a background-fetch event on a device (insert *<your.application.id>*) (only works for sdk `21+`: 201 | ```bash 202 | $ adb shell cmd jobscheduler run -f 999 203 | ``` 204 | - For devices with sdk `<21`, simulate a "Headless JS" event with (insert *<your.application.id>*) 205 | ```bash 206 | $ adb shell am broadcast -a .event.BACKGROUND_FETCH 207 | 208 | ``` 209 | 210 | ## Implementation 211 | 212 | ### iOS 213 | 214 | Implements [performFetchWithCompletionHandler](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplicationDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/UIApplicationDelegate/application:performFetchWithCompletionHandler:), firing a custom event subscribed-to in cordova plugin. 215 | 216 | ### Android 217 | 218 | Android implements background fetch using two different mechanisms, depending on the Android SDK version. Where the SDK version is `>= LOLLIPOP`, the new [`JobScheduler`](https://developer.android.com/reference/android/app/job/JobScheduler.html) API is used. Otherwise, the old [`AlarmManager`](https://developer.android.com/reference/android/app/AlarmManager.html) will be used. 219 | 220 | Unlike iOS, the Android implementation *can* continue to operate after application terminate (`stopOnTerminate: false`) or device reboot (`startOnBoot: true`). 221 | 222 | 223 | 224 | ## Licence ## 225 | 226 | The MIT License 227 | 228 | Copyright (c) 2013 Chris Scott, Transistor Software 229 | http://transistorsoft.com 230 | 231 | Permission is hereby granted, free of charge, to any person obtaining a copy 232 | of this software and associated documentation files (the "Software"), to deal 233 | in the Software without restriction, including without limitation the rights 234 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 235 | copies of the Software, and to permit persons to whom the Software is 236 | furnished to do so, subject to the following conditions: 237 | 238 | The above copyright notice and this permission notice shall be included in 239 | all copies or substantial portions of the Software. 240 | 241 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 242 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 243 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 244 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 245 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 246 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 247 | THE SOFTWARE. 248 | -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/app.gradle: -------------------------------------------------------------------------------- 1 | // Add your native dependencies here: 2 | 3 | // Uncomment to add recyclerview-v7 dependency 4 | //dependencies { 5 | // compile 'com.android.support:recyclerview-v7:+' 6 | //} 7 | 8 | android { 9 | defaultConfig { 10 | generatedDensities = [] 11 | applicationId = "com.transistorsoft.backgroundfetch.nativescript.demo" 12 | } 13 | aaptOptions { 14 | additionalParameters "--no-version-vectors" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 13 | 16 | 17 | 18 | 19 | 20 | 21 | 27 | 28 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-hdpi/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/Android/src/main/res/drawable-hdpi/background.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-hdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/Android/src/main/res/drawable-hdpi/icon.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-hdpi/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/Android/src/main/res/drawable-hdpi/logo.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-ldpi/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/Android/src/main/res/drawable-ldpi/background.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-ldpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/Android/src/main/res/drawable-ldpi/icon.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-ldpi/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/Android/src/main/res/drawable-ldpi/logo.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-mdpi/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/Android/src/main/res/drawable-mdpi/background.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-mdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/Android/src/main/res/drawable-mdpi/icon.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-mdpi/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/Android/src/main/res/drawable-mdpi/logo.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-nodpi/splash_screen.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-xhdpi/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/Android/src/main/res/drawable-xhdpi/background.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-xhdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/Android/src/main/res/drawable-xhdpi/icon.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-xhdpi/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/Android/src/main/res/drawable-xhdpi/logo.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-xxhdpi/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/Android/src/main/res/drawable-xxhdpi/background.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-xxhdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/Android/src/main/res/drawable-xxhdpi/icon.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-xxhdpi/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/Android/src/main/res/drawable-xxhdpi/logo.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-xxxhdpi/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/Android/src/main/res/drawable-xxxhdpi/background.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-xxxhdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/Android/src/main/res/drawable-xxxhdpi/icon.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-xxxhdpi/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/Android/src/main/res/drawable-xxxhdpi/logo.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/values-v21/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3d5afe 4 | -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 11 | 14 | 15 | 16 | 19 | 20 | 23 | -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #F5F5F5 4 | #757575 5 | #33B5E5 6 | #272734 7 | -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 18 | 19 | 21 | 22 | 23 | 31 | 32 | 34 | 35 | 36 | 42 | 43 | 45 | 46 | -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "29x29", 5 | "idiom" : "iphone", 6 | "filename" : "icon-29.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "29x29", 11 | "idiom" : "iphone", 12 | "filename" : "icon-29@2x.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "icon-29@3x.png", 19 | "scale" : "3x" 20 | }, 21 | { 22 | "size" : "40x40", 23 | "idiom" : "iphone", 24 | "filename" : "icon-40@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "40x40", 29 | "idiom" : "iphone", 30 | "filename" : "icon-40@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "57x57", 35 | "idiom" : "iphone", 36 | "filename" : "icon-57.png", 37 | "scale" : "1x" 38 | }, 39 | { 40 | "size" : "57x57", 41 | "idiom" : "iphone", 42 | "filename" : "icon-57@2x.png", 43 | "scale" : "2x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "icon-60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "icon-60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "29x29", 59 | "idiom" : "ipad", 60 | "filename" : "icon-29.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "29x29", 65 | "idiom" : "ipad", 66 | "filename" : "icon-29@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "40x40", 71 | "idiom" : "ipad", 72 | "filename" : "icon-40.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "40x40", 77 | "idiom" : "ipad", 78 | "filename" : "icon-40@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "50x50", 83 | "idiom" : "ipad", 84 | "filename" : "icon-50.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "50x50", 89 | "idiom" : "ipad", 90 | "filename" : "icon-50@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "72x72", 95 | "idiom" : "ipad", 96 | "filename" : "icon-72.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "72x72", 101 | "idiom" : "ipad", 102 | "filename" : "icon-72@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "76x76", 107 | "idiom" : "ipad", 108 | "filename" : "icon-76.png", 109 | "scale" : "1x" 110 | }, 111 | { 112 | "size" : "76x76", 113 | "idiom" : "ipad", 114 | "filename" : "icon-76@2x.png", 115 | "scale" : "2x" 116 | }, 117 | { 118 | "size" : "83.5x83.5", 119 | "idiom" : "ipad", 120 | "filename" : "icon-83.5@2x.png", 121 | "scale" : "2x" 122 | } 123 | ], 124 | "info" : { 125 | "version" : 1, 126 | "author" : "xcode" 127 | } 128 | } -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@3x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "extent" : "full-screen", 5 | "idiom" : "iphone", 6 | "subtype" : "736h", 7 | "filename" : "Default-736h@3x.png", 8 | "minimum-system-version" : "8.0", 9 | "orientation" : "portrait", 10 | "scale" : "3x" 11 | }, 12 | { 13 | "extent" : "full-screen", 14 | "idiom" : "iphone", 15 | "subtype" : "736h", 16 | "filename" : "Default-Landscape@3x.png", 17 | "minimum-system-version" : "8.0", 18 | "orientation" : "landscape", 19 | "scale" : "3x" 20 | }, 21 | { 22 | "extent" : "full-screen", 23 | "idiom" : "iphone", 24 | "subtype" : "667h", 25 | "filename" : "Default-667h@2x.png", 26 | "minimum-system-version" : "8.0", 27 | "orientation" : "portrait", 28 | "scale" : "2x" 29 | }, 30 | { 31 | "orientation" : "portrait", 32 | "idiom" : "iphone", 33 | "filename" : "Default@2x.png", 34 | "extent" : "full-screen", 35 | "minimum-system-version" : "7.0", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "extent" : "full-screen", 40 | "idiom" : "iphone", 41 | "subtype" : "retina4", 42 | "filename" : "Default-568h@2x.png", 43 | "minimum-system-version" : "7.0", 44 | "orientation" : "portrait", 45 | "scale" : "2x" 46 | }, 47 | { 48 | "orientation" : "portrait", 49 | "idiom" : "ipad", 50 | "filename" : "Default-Portrait.png", 51 | "extent" : "full-screen", 52 | "minimum-system-version" : "7.0", 53 | "scale" : "1x" 54 | }, 55 | { 56 | "orientation" : "landscape", 57 | "idiom" : "ipad", 58 | "filename" : "Default-Landscape.png", 59 | "extent" : "full-screen", 60 | "minimum-system-version" : "7.0", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "orientation" : "portrait", 65 | "idiom" : "ipad", 66 | "filename" : "Default-Portrait@2x.png", 67 | "extent" : "full-screen", 68 | "minimum-system-version" : "7.0", 69 | "scale" : "2x" 70 | }, 71 | { 72 | "orientation" : "landscape", 73 | "idiom" : "ipad", 74 | "filename" : "Default-Landscape@2x.png", 75 | "extent" : "full-screen", 76 | "minimum-system-version" : "7.0", 77 | "scale" : "2x" 78 | }, 79 | { 80 | "orientation" : "portrait", 81 | "idiom" : "iphone", 82 | "filename" : "Default.png", 83 | "extent" : "full-screen", 84 | "scale" : "1x" 85 | }, 86 | { 87 | "orientation" : "portrait", 88 | "idiom" : "iphone", 89 | "filename" : "Default@2x.png", 90 | "extent" : "full-screen", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "orientation" : "portrait", 95 | "idiom" : "iphone", 96 | "filename" : "Default-568h@2x.png", 97 | "extent" : "full-screen", 98 | "subtype" : "retina4", 99 | "scale" : "2x" 100 | }, 101 | { 102 | "orientation" : "portrait", 103 | "idiom" : "ipad", 104 | "extent" : "to-status-bar", 105 | "scale" : "1x" 106 | }, 107 | { 108 | "orientation" : "portrait", 109 | "idiom" : "ipad", 110 | "filename" : "Default-Portrait.png", 111 | "extent" : "full-screen", 112 | "scale" : "1x" 113 | }, 114 | { 115 | "orientation" : "landscape", 116 | "idiom" : "ipad", 117 | "extent" : "to-status-bar", 118 | "scale" : "1x" 119 | }, 120 | { 121 | "orientation" : "landscape", 122 | "idiom" : "ipad", 123 | "filename" : "Default-Landscape.png", 124 | "extent" : "full-screen", 125 | "scale" : "1x" 126 | }, 127 | { 128 | "orientation" : "portrait", 129 | "idiom" : "ipad", 130 | "extent" : "to-status-bar", 131 | "scale" : "2x" 132 | }, 133 | { 134 | "orientation" : "portrait", 135 | "idiom" : "ipad", 136 | "filename" : "Default-Portrait@2x.png", 137 | "extent" : "full-screen", 138 | "scale" : "2x" 139 | }, 140 | { 141 | "orientation" : "landscape", 142 | "idiom" : "ipad", 143 | "extent" : "to-status-bar", 144 | "scale" : "2x" 145 | }, 146 | { 147 | "orientation" : "landscape", 148 | "idiom" : "ipad", 149 | "filename" : "Default-Landscape@2x.png", 150 | "extent" : "full-screen", 151 | "scale" : "2x" 152 | } 153 | ], 154 | "info" : { 155 | "version" : 1, 156 | "author" : "xcode" 157 | } 158 | } -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-568h@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-667h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-667h@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-736h@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-736h@3x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@3x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchScreen-AspectFill.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchScreen-AspectFill@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchScreen-Center.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchScreen-Center@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIRequiresFullScreen 28 | 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/build.xcconfig: -------------------------------------------------------------------------------- 1 | // You can add custom settings here 2 | // for example you can uncomment the following line to force distribution code signing 3 | // CODE_SIGN_IDENTITY = iPhone Distribution 4 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 5 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 6 | -------------------------------------------------------------------------------- /demo/app/app-root.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /demo/app/app.css: -------------------------------------------------------------------------------- 1 | /* 2 | In NativeScript, the app.css file is where you place CSS rules that 3 | you would like to apply to your entire application. Check out 4 | http://docs.nativescript.org/ui/styling for a full list of the CSS 5 | selectors and properties you can use to style UI components. 6 | 7 | /* 8 | In many cases you may want to use the NativeScript core theme instead 9 | of writing your own CSS rules. For a full list of class names in the theme 10 | refer to http://docs.nativescript.org/ui/theme. 11 | The imported CSS rules must precede all other types of rules. 12 | */ 13 | @import '~nativescript-theme-core/css/core.light.css'; 14 | 15 | /* 16 | The following CSS rule changes the font size of all UI 17 | components that have the btn class name. 18 | */ 19 | .btn { 20 | font-size: 18; 21 | } 22 | 23 | .title { 24 | font-size: 30; 25 | horizontal-align: center; 26 | margin: 20; 27 | } 28 | 29 | button { 30 | font-size: 42; 31 | horizontal-align: center; 32 | } 33 | 34 | .message { 35 | font-size: 20; 36 | color: #284848; 37 | horizontal-align: center; 38 | margin: 0 20; 39 | text-align: center; 40 | } 41 | -------------------------------------------------------------------------------- /demo/app/app.ts: -------------------------------------------------------------------------------- 1 | import "./bundle-config"; 2 | import * as application from 'application'; 3 | 4 | import {BackgroundFetch} from "nativescript-background-fetch"; 5 | 6 | declare var TSBackgroundFetch: any; 7 | 8 | if (application.ios) { 9 | class MyDelegate extends UIResponder { 10 | public static ObjCProtocols = [UIApplicationDelegate]; 11 | 12 | public applicationPerformFetchWithCompletionHandler(application: UIApplication, completionHandler:any) { 13 | console.log('- AppDelegate Rx Fetch event'); 14 | BackgroundFetch.performFetchWithCompletionHandler(completionHandler, application.applicationState); 15 | } 16 | } 17 | application.ios.delegate = MyDelegate; 18 | } else if (application.android) { 19 | BackgroundFetch.registerHeadlessTask(async () => { 20 | console.log('[BackgroundFetch] Demo Headless Task'); 21 | let result = await doWork(); 22 | BackgroundFetch.finish(); 23 | }); 24 | 25 | let doWork = () => { 26 | return new Promise((resolve, reject) => { 27 | // Do some work. 28 | let result = true; 29 | if (result) { 30 | resolve('OK') 31 | } else { 32 | reject('OOPS!'); 33 | } 34 | }); 35 | } 36 | 37 | } 38 | 39 | application.run({ moduleName: 'app-root' }); 40 | -------------------------------------------------------------------------------- /demo/app/bundle-config.ts: -------------------------------------------------------------------------------- 1 | if ((global).TNS_WEBPACK) { 2 | // Register tns-core-modules UI framework modules 3 | require("bundle-entry-points"); 4 | 5 | // Register application modules 6 | // This will register each `root`, `page`, `fragment` postfixed xml, css, js, ts, scss file in the app/ folder 7 | const context = (require).context("~/", true, /(root|page|fragment)\.(xml|css|js|ts|scss|less|sass)$/); 8 | global.registerWebpackModules(context); 9 | } 10 | -------------------------------------------------------------------------------- /demo/app/main-page.ts: -------------------------------------------------------------------------------- 1 | import { EventData } from "data/observable"; 2 | import { Page } from "ui/page"; 3 | import { HelloWorldModel } from "./main-view-model"; 4 | 5 | // Event handler for Page "navigatingTo" event attached in main-page.xml 6 | export function navigatingTo(args: EventData) { 7 | // Get the event sender 8 | var page = args.object; 9 | page.bindingContext = new HelloWorldModel(); 10 | } -------------------------------------------------------------------------------- /demo/app/main-page.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 24 | 25 | -------------------------------------------------------------------------------- /demo/app/main-view-model.ts: -------------------------------------------------------------------------------- 1 | import observable = require("data/observable"); 2 | import Platform = require('platform'); 3 | import {BackgroundFetch} from "nativescript-background-fetch"; 4 | 5 | export class HelloWorldModel extends observable.Observable { 6 | private _counter: number; 7 | private _message: string; 8 | private _fetchManager: BackgroundFetch; 9 | private _platform: any; 10 | 11 | get platform():any { 12 | return Platform; 13 | } 14 | 15 | get message(): string { 16 | return this._message; 17 | } 18 | set message(value: string) { 19 | if (this._message !== value) { 20 | this._message = value; 21 | this.notifyPropertyChange("message", value) 22 | } 23 | } 24 | 25 | constructor() { 26 | super(); 27 | 28 | BackgroundFetch.configure({ 29 | minimumFetchInterval: 15, 30 | stopOnTerminate: false, 31 | startOnBoot: true, 32 | enableHeadless: true 33 | }, function() { 34 | console.log('[BackgroundFetch] Event Received!'); 35 | this._counter++; 36 | this.updateMessage(); 37 | BackgroundFetch.finish(BackgroundFetch.FETCH_RESULT_NEW_DATA); 38 | }.bind(this), function(error) { 39 | console.log('[BackgroundFetch] FAILED'); 40 | }.bind(this)); 41 | 42 | // Initialize default values. 43 | this._counter = 0; 44 | this.updateMessage(); 45 | } 46 | 47 | private updateMessage() { 48 | this.message = this._counter + " BackgroundFetch events received"; 49 | } 50 | 51 | public onTap() { 52 | this._counter--; 53 | this.updateMessage(); 54 | } 55 | } 56 | 57 | /* 58 | if (application.android) { 59 | BackgroundFetch.registerHeadlessTask(async () => { 60 | console.log('[BackgroundFetch] Demo Headless Task'); 61 | let result = await doWork(); 62 | BackgroundFetch.finish(); 63 | }); 64 | 65 | let doWork = () => { 66 | return new Promise((resolve, reject) => { 67 | // Do some work. 68 | let result = true; 69 | if (result) { 70 | resolve('OK') 71 | } else { 72 | reject('OOPS!'); 73 | } 74 | }); 75 | } 76 | 77 | } 78 | */ -------------------------------------------------------------------------------- /demo/app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tns-template-hello-world-ts", 3 | "main": "app.js", 4 | "version": "2.1.0", 5 | "author": "Telerik ", 6 | "description": "Nativescript hello-world-ts project template", 7 | "license": "Apache-2.0", 8 | "keywords": [ 9 | "telerik", 10 | "mobile", 11 | "nativescript", 12 | "{N}", 13 | "tns", 14 | "appbuilder", 15 | "template" 16 | ], 17 | "repository": { 18 | "type": "git", 19 | "url": "git@github.com:NativeScript/template-hello-world-ts.git" 20 | }, 21 | "bugs": { 22 | "url": "https://github.com/NativeScript/template-hello-world-ts/issues" 23 | }, 24 | "homepage": "https://github.com/NativeScript/template-hello-world-ts", 25 | "android": { 26 | "v8Flags": "--expose_gc" 27 | }, 28 | "devDependencies": { 29 | "nativescript-dev-typescript": "^0.3.2" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /demo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "NativeScript Application", 3 | "license": "SEE LICENSE IN ", 4 | "readme": "NativeScript Application", 5 | "repository": "", 6 | "nativescript": { 7 | "id": "com.transistorsoft.backgroundfetch.nativescript.demo", 8 | "tns-android": { 9 | "version": "4.1.3" 10 | }, 11 | "tns-ios": { 12 | "version": "4.1.0" 13 | } 14 | }, 15 | "dependencies": { 16 | "nativescript-background-fetch": "file:../src", 17 | "nativescript-theme-core": "~1.0.4", 18 | "tns-core-modules": "4.1.0" 19 | }, 20 | "devDependencies": { 21 | "babel-traverse": "6.26.0", 22 | "babel-types": "6.26.0", 23 | "babylon": "6.18.0", 24 | "lazy": "1.0.11", 25 | "nativescript-dev-typescript": "^0.7.0", 26 | "typescript": "~2.7.2", 27 | "tns-platform-declarations": "^4.1.0" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /demo/references.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | -------------------------------------------------------------------------------- /demo/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es5", 5 | "experimentalDecorators": true, 6 | "emitDecoratorMetadata": true, 7 | "noEmitHelpers": true, 8 | "noEmitOnError": true, 9 | "lib": [ 10 | "es6", 11 | "dom" 12 | ], 13 | "baseUrl": ".", 14 | "paths": { 15 | "~/*": [ 16 | "app/*" 17 | ], 18 | "*": [ 19 | "./node_modules/tns-core-modules/*", 20 | "./node_modules/*" 21 | ] 22 | } 23 | }, 24 | "exclude": [ 25 | "node_modules", 26 | "platforms" 27 | ] 28 | } -------------------------------------------------------------------------------- /src/.npmignore: -------------------------------------------------------------------------------- 1 | demo/ 2 | *.png 3 | *.log 4 | *.ts 5 | !*.d.ts 6 | -------------------------------------------------------------------------------- /src/HeadlessBroadcastReceiver.android.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /src/HeadlessBroadcastReceiver.android.ts: -------------------------------------------------------------------------------- 1 | import HeadlessTask from "./headless-task"; 2 | 3 | declare var com: any; 4 | 5 | let Fetch = com.transistorsoft.tsbackgroundfetch.BackgroundFetch; 6 | 7 | @JavaProxy("com.transistorsoft.backgroundfetch.HeadlessBroadcastReceiver") 8 | class HeadlessBroadcastReceiver extends android.content.BroadcastReceiver { 9 | public onReceive(context:android.content.Context, intent:android.content.Intent) { 10 | let adapter = Fetch.getInstance(context); 11 | if (adapter.isMainActivityActive().booleanValue()) { 12 | return; 13 | } 14 | HeadlessTask.invokeHeadlessTask(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/HeadlessJobService.android.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /src/HeadlessJobService.android.ts: -------------------------------------------------------------------------------- 1 | import HeadlessTask from "./headless-task"; 2 | 3 | declare var com: any; 4 | let Fetch = com.transistorsoft.tsbackgroundfetch.BackgroundFetch; 5 | let CompletionHandler = com.transistorsoft.tsbackgroundfetch.FetchJobService.CompletionHandler; 6 | 7 | @JavaProxy("com.transistorsoft.backgroundfetch.HeadlessJobService") 8 | class HeadlessJobService extends android.app.job.JobService { 9 | public onStartJob(params:android.app.job.JobParameters):boolean { 10 | Fetch.getInstance(this.getApplicationContext()).registerCompletionHandler(new CompletionHandler({ 11 | finish: () => { 12 | console.log('[HeadlessJobService] finish'); 13 | this.jobFinished(params, false); 14 | } 15 | })); 16 | if (!HeadlessTask.invokeHeadlessTask()) { 17 | this.jobFinished(params, false); 18 | } 19 | return true; 20 | } 21 | 22 | public onStopJob(params:android.app.job.JobParameters):boolean { 23 | this.jobFinished(params, false); 24 | return true; 25 | } 26 | } 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/background-fetch.android.d.ts: -------------------------------------------------------------------------------- 1 | import 'nativescript-tslib'; 2 | import "./HeadlessBroadcastReceiver"; 3 | import "./HeadlessJobService"; 4 | import { AbstractBackgroundFetch } from "./common"; 5 | export declare class BackgroundFetch extends AbstractBackgroundFetch { 6 | private static configured; 7 | private static isForceReload; 8 | private static intent; 9 | static registerHeadlessTask(callback: Function): void; 10 | static configure(params: any, success: Function, failure?: Function): void; 11 | static start(success?: Function, failure?: Function): void; 12 | static stop(success?: Function, failure?: Function): void; 13 | static finish(result?: number): void; 14 | static status(success: Function): void; 15 | private static init; 16 | private static getAdapter; 17 | } 18 | -------------------------------------------------------------------------------- /src/background-fetch.android.ts: -------------------------------------------------------------------------------- 1 | // importing this solves issues with __awaiter not defined using await in Android HeadlessTask 2 | import 'nativescript-tslib'; 3 | 4 | import "./HeadlessBroadcastReceiver"; 5 | import "./HeadlessJobService"; 6 | 7 | import {AbstractBackgroundFetch} from "./common"; 8 | import HeadlessTask from "./headless-task"; 9 | 10 | declare var com: any; 11 | 12 | var emptyFn = function() {}; 13 | 14 | import app = require('application'); 15 | 16 | 17 | let Fetch = com.transistorsoft.tsbackgroundfetch.BackgroundFetch; 18 | let FetchConfig = com.transistorsoft.tsbackgroundfetch.BackgroundFetchConfig 19 | 20 | export class BackgroundFetch extends AbstractBackgroundFetch { 21 | private static configured: boolean; 22 | private static isForceReload:boolean = false; 23 | private static intent:android.content.Intent; 24 | 25 | public static registerHeadlessTask(callback:Function) { 26 | HeadlessTask.registerHeadlessTask(callback); 27 | } 28 | 29 | public static configure(params:any, success:Function, failure?:Function) { 30 | let builder = new FetchConfig.Builder(); 31 | if (typeof(params.minimumFetchInterval) === 'number') { 32 | builder.setMinimumFetchInterval(params.minimumFetchInterval); 33 | } 34 | if (typeof(params.stopOnTerminate) === 'boolean') { 35 | builder.setStopOnTerminate(params.stopOnTerminate); 36 | } 37 | if (typeof(params.forceReload) === 'boolean') { 38 | builder.setForceReload(params.forceReload); 39 | } 40 | if (typeof(params.startOnBoot) === 'boolean') { 41 | builder.setStartOnBoot(params.startOnBoot); 42 | } 43 | if (params.enableHeadless === true) { 44 | builder.setJobService('com.transistorsoft.backgroundfetch.HeadlessJobService'); 45 | } 46 | let adapter = this.getAdapter(); 47 | let callback = new Fetch.Callback({ 48 | onFetch: success 49 | }); 50 | adapter.configure(builder.build(), callback); 51 | 52 | if (this.isForceReload) { 53 | callback.onFetch(); 54 | } 55 | } 56 | public static start(success?:Function, failure?:Function) { 57 | success = success || emptyFn; 58 | let adapter = this.getAdapter(); 59 | adapter.start(); 60 | success(); 61 | } 62 | public static stop(success?:Function, failure?:Function) { 63 | success = success || emptyFn; 64 | let adapter = this.getAdapter(); 65 | adapter.stop(); 66 | success(); 67 | } 68 | public static finish(result?:number) { 69 | let adapter = this.getAdapter(); 70 | adapter.finish(); 71 | } 72 | public static status(success:Function) {} 73 | 74 | private static init() { 75 | if (!app.android.startActivity || (this.intent !== null)) { 76 | return; 77 | } 78 | this.intent = app.android.startActivity.getIntent(); 79 | let action = this.intent.getAction(); 80 | if ((action != null) && (Fetch.ACTION_FORCE_RELOAD.toUpperCase() === action)) { 81 | this.isForceReload = true; 82 | app.android.startActivity.moveTaskToBack(true); 83 | } 84 | } 85 | 86 | private static getAdapter() { 87 | if (!this.intent) { 88 | this.init(); 89 | } 90 | return Fetch.getInstance(app.android.context.getApplicationContext()); 91 | } 92 | } -------------------------------------------------------------------------------- /src/background-fetch.d.ts: -------------------------------------------------------------------------------- 1 | 2 | export * from "./background-fetch.ios"; 3 | -------------------------------------------------------------------------------- /src/background-fetch.ios.d.ts: -------------------------------------------------------------------------------- 1 | import { AbstractBackgroundFetch } from "./common"; 2 | export declare class BackgroundFetch extends AbstractBackgroundFetch { 3 | private static configured; 4 | static performFetchWithCompletionHandler(completionHandler: Function, state: UIApplicationState): void; 5 | static configure(config: Object, callback: Function, failure?: Function): void; 6 | static start(success?: Function, failure?: Function): void; 7 | static stop(success?: Function, failure?: Function): void; 8 | static status(success: Function): void; 9 | static finish(result?: number): void; 10 | static registerHeadlessTask(callback: Function): void; 11 | } 12 | -------------------------------------------------------------------------------- /src/background-fetch.ios.ts: -------------------------------------------------------------------------------- 1 | import {AbstractBackgroundFetch} from "./common"; 2 | 3 | declare var TSBackgroundFetch: any; 4 | 5 | let TAG = "NSBackgroundFetch"; 6 | 7 | var emptyFn = function() {}; 8 | 9 | export class BackgroundFetch extends AbstractBackgroundFetch { 10 | private static configured: boolean; 11 | 12 | public static performFetchWithCompletionHandler(completionHandler:Function, state:UIApplicationState, ) { 13 | TSBackgroundFetch.sharedInstance().performFetchWithCompletionHandlerApplicationState(completionHandler, state); 14 | } 15 | 16 | public static configure(config:Object, callback:Function, failure?:Function) { 17 | let fetchManager = TSBackgroundFetch.sharedInstance(); 18 | 19 | fetchManager.configureCallback(config, (status:UIBackgroundRefreshStatus) => { 20 | if (status != UIBackgroundRefreshStatus.Available) { 21 | console.warn(TAG, "failed to start TSBackgroundFetch"); 22 | failure(status); 23 | return; 24 | } 25 | this.configured = true; 26 | fetchManager.addListenerCallback(TAG, callback); 27 | fetchManager.start(); 28 | }); 29 | } 30 | public static start(success?:Function, failure?:Function) { 31 | success = success || emptyFn; 32 | failure = failure || emptyFn; 33 | 34 | TSBackgroundFetch.sharedInstance().start((status:UIBackgroundRefreshStatus) => { 35 | if (status == UIBackgroundRefreshStatus.Available) { 36 | success(); 37 | } else { 38 | console.warn(TAG, "failed to start TSBackgroundFetch"); 39 | failure(status); 40 | } 41 | }); 42 | } 43 | 44 | public static stop(success?:Function, failure?:Function) { 45 | success = success || emptyFn; 46 | failure = failure || emptyFn; 47 | 48 | TSBackgroundFetch.sharedInstance().stop(); 49 | success(); 50 | } 51 | 52 | public static status(success:Function) { 53 | TSBackgroundFetch.sharedInstance().status((status:UIBackgroundRefreshStatus) => { 54 | success(status); 55 | }); 56 | } 57 | 58 | public static finish(result?:number) { 59 | result = result || this.FETCH_RESULT_NO_DATA; 60 | TSBackgroundFetch.sharedInstance().finishResult(TAG, result); 61 | } 62 | 63 | // Note: Android-only 64 | public static registerHeadlessTask(callback:Function) {} 65 | 66 | } -------------------------------------------------------------------------------- /src/common.d.ts: -------------------------------------------------------------------------------- 1 | export declare class AbstractBackgroundFetch { 2 | static STATUS_RESTRICTED: number; 3 | static STATUS_DENIED: number; 4 | static STATUS_AVAILABLE: number; 5 | static FETCH_RESULT_NEW_DATA: number; 6 | static FETCH_RESULT_NO_DATA: number; 7 | static FETCH_RESULT_FAILED: number; 8 | } 9 | -------------------------------------------------------------------------------- /src/common.ts: -------------------------------------------------------------------------------- 1 | export class AbstractBackgroundFetch { 2 | public static STATUS_RESTRICTED:number = 0; 3 | public static STATUS_DENIED:number = 1; 4 | public static STATUS_AVAILABLE:number = 2; 5 | 6 | public static FETCH_RESULT_NEW_DATA:number = 0; 7 | public static FETCH_RESULT_NO_DATA:number = 1; 8 | public static FETCH_RESULT_FAILED:number = 2; 9 | } -------------------------------------------------------------------------------- /src/headless-task.d.ts: -------------------------------------------------------------------------------- 1 | export default class HeadlessTask { 2 | private static headlessTask; 3 | static registerHeadlessTask(callback: Function): void; 4 | static invokeHeadlessTask(): boolean; 5 | } 6 | -------------------------------------------------------------------------------- /src/headless-task.ts: -------------------------------------------------------------------------------- 1 | export default class HeadlessTask { 2 | private static headlessTask: Function; 3 | 4 | public static registerHeadlessTask(callback:Function) { 5 | this.headlessTask = callback; 6 | } 7 | 8 | public static invokeHeadlessTask():boolean { 9 | if (!this.headlessTask) { 10 | console.log('[BackgroundFetch] invokeHeadlessTask ERROR - headlessTask is null. Did you BackgroundFetch.registerHeadlessTask(myTask) in your app.ts?'); 11 | return false; 12 | } 13 | this.headlessTask(); 14 | return true; 15 | } 16 | } -------------------------------------------------------------------------------- /src/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nativescript-background-fetch", 3 | "version": "1.2.1", 4 | "description": "iOS Background Fetch API Implementation for NativeScript", 5 | "main": "background-fetch", 6 | "typings": "background-fetch.d.ts", 7 | "nativescript": { 8 | "platforms": { 9 | "ios": "2.0.0", 10 | "android": "2.0.0" 11 | }, 12 | "tns-ios": { 13 | "version": "5.1.0" 14 | } 15 | }, 16 | "scripts": { 17 | "build": "tsc", 18 | "demo.ios": "npm run preparedemo && cd demo && tns emulate ios", 19 | "demo.android": "npm run preparedemo && cd demo && tns run android", 20 | "preparedemo": "npm run build && cd demo && tns plugin remove nativescript-background-fetch && tns plugin add .. && tns install", 21 | "setup": "cd demo && npm install && cd .. && npm run build && cd demo && tns plugin add .. && cd ..", 22 | "fix-xcode": "xcproj --project 'demo/platforms/ios/demo.xcodeproj' touch && xcproj --project 'demo/platforms/ios/Pods/Pods.xcodeproj' touch" 23 | }, 24 | "repository": { 25 | "type": "git", 26 | "url": "https://github.com/transistorsoft/nativescript-background-fetch.git" 27 | }, 28 | "keywords": [ 29 | "NativeScript", 30 | "JavaScript", 31 | "background fetch", 32 | "iOS" 33 | ], 34 | "author": { 35 | "name": "Chris Scott, Transistor Software", 36 | "email": "chris@transistorsoft.com" 37 | }, 38 | "bugs": { 39 | "url": "https://github.com/transistorsoft/nativescript-background-fetch/issues" 40 | }, 41 | "license": "MIT", 42 | "homepage": "https://github.com/transistorsoft/nativescript-background-fetch", 43 | "readmeFilename": "README.md", 44 | "devDependencies": { 45 | "nativescript-dev-typescript": "^0.5.0", 46 | "tns-core-modules": "^5.1.0", 47 | "tns-platform-declarations": "^5.1.0", 48 | "typescript": "^2.2.2" 49 | }, 50 | "peerDependencies": { 51 | "tns-core-modules": "^5.1.0" 52 | }, 53 | "dependencies": { 54 | "nativescript-tslib": "^1.9.1-r1" 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/platforms/android/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/platforms/android/include.gradle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/src/platforms/android/include.gradle -------------------------------------------------------------------------------- /src/platforms/android/libs/tsbackgroundfetch.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/src/platforms/android/libs/tsbackgroundfetch.aar -------------------------------------------------------------------------------- /src/platforms/ios/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UIBackgroundModes 6 | 7 | fetch 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/platforms/ios/Podfile: -------------------------------------------------------------------------------- 1 | pod 'nativescript-background-fetch', :path => '../../node_modules/nativescript-background-fetch/platforms/ios' 2 | -------------------------------------------------------------------------------- /src/platforms/ios/TSBackgroundFetch.framework/Headers/TSBackgroundFetch.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNBackgroundFetchManager.h 3 | // RNBackgroundFetch 4 | // 5 | // Created by Christopher Scott on 2016-08-02. 6 | // Copyright © 2016 Christopher Scott. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface TSBackgroundFetch : NSObject 13 | 14 | @property (nonatomic) BOOL stopOnTerminate; 15 | @property (readonly) BOOL configured; 16 | @property (readonly) BOOL active; 17 | 18 | + (TSBackgroundFetch *)sharedInstance; 19 | -(void) performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))handler applicationState:(UIApplicationState)state; 20 | -(void) configure:(NSDictionary*)config callback:(void(^)(UIBackgroundRefreshStatus status))callback; 21 | -(void) configure:(NSDictionary*)config; 22 | -(void) addListener:(NSString*)componentName callback:(void (^)(void))callback; 23 | -(void) removeListener:(NSString*)componentName; 24 | -(BOOL) hasListener:(NSString*)componentName; 25 | -(void) start:(void(^)(UIBackgroundRefreshStatus status))callback; 26 | -(void) start; 27 | -(void) stop; 28 | -(void) finish:(NSString*)tag result:(UIBackgroundFetchResult) result; 29 | -(void) status:(void(^)(UIBackgroundRefreshStatus status))callback; 30 | 31 | @end 32 | 33 | -------------------------------------------------------------------------------- /src/platforms/ios/TSBackgroundFetch.framework/Info.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/src/platforms/ios/TSBackgroundFetch.framework/Info.plist -------------------------------------------------------------------------------- /src/platforms/ios/TSBackgroundFetch.framework/Modules/module.modulemap: -------------------------------------------------------------------------------- 1 | framework module TSBackgroundFetch { 2 | umbrella header "TSBackgroundFetch.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /src/platforms/ios/TSBackgroundFetch.framework/TSBackgroundFetch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/src/platforms/ios/TSBackgroundFetch.framework/TSBackgroundFetch -------------------------------------------------------------------------------- /src/platforms/ios/TSBackgroundFetch.framework/_CodeSignature/CodeDirectory: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/src/platforms/ios/TSBackgroundFetch.framework/_CodeSignature/CodeDirectory -------------------------------------------------------------------------------- /src/platforms/ios/TSBackgroundFetch.framework/_CodeSignature/CodeRequirements: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/src/platforms/ios/TSBackgroundFetch.framework/_CodeSignature/CodeRequirements -------------------------------------------------------------------------------- /src/platforms/ios/TSBackgroundFetch.framework/_CodeSignature/CodeRequirements-1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/src/platforms/ios/TSBackgroundFetch.framework/_CodeSignature/CodeRequirements-1 -------------------------------------------------------------------------------- /src/platforms/ios/TSBackgroundFetch.framework/_CodeSignature/CodeResources: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | files 6 | 7 | Headers/TSBackgroundFetch.h 8 | 9 | 6IaHDuPW1C0nWBp03yKGD5PrgTY= 10 | 11 | Info.plist 12 | 13 | /q6b6t8hcxgtnV2U/r/pxyTm1is= 14 | 15 | Modules/module.modulemap 16 | 17 | 4NbofBeHHFHeUWRZ1ZcIkl3/T3w= 18 | 19 | 20 | files2 21 | 22 | Headers/TSBackgroundFetch.h 23 | 24 | hash 25 | 26 | 6IaHDuPW1C0nWBp03yKGD5PrgTY= 27 | 28 | hash2 29 | 30 | Q6MbZjcbrHTACLwceQDEESRGhY9/uOOu7bCb71fOAfk= 31 | 32 | 33 | Modules/module.modulemap 34 | 35 | hash 36 | 37 | 4NbofBeHHFHeUWRZ1ZcIkl3/T3w= 38 | 39 | hash2 40 | 41 | ZZoRDGe9SOWekYXO71UHMmkagz+I18vRneUTVMd0WnY= 42 | 43 | 44 | 45 | rules 46 | 47 | ^ 48 | 49 | ^.*\.lproj/ 50 | 51 | optional 52 | 53 | weight 54 | 1000 55 | 56 | ^.*\.lproj/locversion.plist$ 57 | 58 | omit 59 | 60 | weight 61 | 1100 62 | 63 | ^Base\.lproj/ 64 | 65 | weight 66 | 1010 67 | 68 | ^version.plist$ 69 | 70 | 71 | rules2 72 | 73 | .*\.dSYM($|/) 74 | 75 | weight 76 | 11 77 | 78 | ^ 79 | 80 | weight 81 | 20 82 | 83 | ^(.*/)?\.DS_Store$ 84 | 85 | omit 86 | 87 | weight 88 | 2000 89 | 90 | ^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/ 91 | 92 | nested 93 | 94 | weight 95 | 10 96 | 97 | ^.* 98 | 99 | ^.*\.lproj/ 100 | 101 | optional 102 | 103 | weight 104 | 1000 105 | 106 | ^.*\.lproj/locversion.plist$ 107 | 108 | omit 109 | 110 | weight 111 | 1100 112 | 113 | ^Base\.lproj/ 114 | 115 | weight 116 | 1010 117 | 118 | ^Info\.plist$ 119 | 120 | omit 121 | 122 | weight 123 | 20 124 | 125 | ^PkgInfo$ 126 | 127 | omit 128 | 129 | weight 130 | 20 131 | 132 | ^[^/]+$ 133 | 134 | nested 135 | 136 | weight 137 | 10 138 | 139 | ^embedded\.provisionprofile$ 140 | 141 | weight 142 | 20 143 | 144 | ^version\.plist$ 145 | 146 | weight 147 | 20 148 | 149 | 150 | 151 | 152 | -------------------------------------------------------------------------------- /src/platforms/ios/TSBackgroundFetch.framework/_CodeSignature/CodeSignature: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/transistorsoft/nativescript-background-fetch/ac20215721e6c78b29ab024fded2bbd43db8d876/src/platforms/ios/TSBackgroundFetch.framework/_CodeSignature/CodeSignature -------------------------------------------------------------------------------- /src/platforms/ios/nativescript-background-fetch.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "nativescript-background-fetch" 3 | s.version = "1.0.1" 4 | s.summary = "iOS Background Fetch API Implementation for NativeScript" 5 | s.author = "Chris Scott, Transistor Software" 6 | s.homepage = "https://github.com/transistorsoft/nativescript-background-fetch" 7 | s.platform = :ios, "7.0" 8 | s.vendored_frameworks = "platforms/ios/TSBackgroundFetch.framework" 9 | s.license = {:type => "MIT"} 10 | s.source = { :path => "../../node_modules/nativescript-background-fetch/platforms/ios" } 11 | end 12 | -------------------------------------------------------------------------------- /src/references.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | 4 | declare module android { 5 | module app { 6 | export module job { 7 | export class JobService extends android.app.Service { 8 | public onStartJob(params:android.app.job.JobParameters):boolean; 9 | public onStopJob(params:android.app.job.JobParameters):boolean; 10 | public jobFinished(params:android.app.job.JobParameters, wantsReschedule:boolean); 11 | } 12 | export class JobParameters { 13 | public getExtras():android.os.PersistableBundle; 14 | } 15 | } 16 | } 17 | module os { 18 | export class PersistableBundle extends java.lang.Object implements android.os.Parcelable, java.lang.Cloneable { 19 | public getString(key: string): string; 20 | public describeContents(): number; 21 | public writeToParcel(parcel: android.os.Parcel, flags: number): void; 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es5", 5 | "noImplicitAny": false, 6 | "noLib": false, 7 | "declaration": true, 8 | "experimentalDecorators": true, 9 | "emitDecoratorMetadata": true, 10 | "noEmitHelpers": true, 11 | "noEmitOnError": false, 12 | "lib": [ 13 | "es6", 14 | "dom" 15 | ], 16 | "baseUrl": ".", 17 | "paths": { 18 | "*": [ 19 | "./node_modules/tns-core-modules/*", 20 | "./node_modules/*" 21 | ] 22 | } 23 | }, 24 | "exclude": [ 25 | "node_modules", 26 | "platforms" 27 | ], 28 | "compileOnSave": false 29 | } --------------------------------------------------------------------------------