2016-06-08 22:25:24 +08:00
|
|
|
import {Plugin, Cordova} from './plugin';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name Background Mode
|
|
|
|
* @description
|
2016-06-08 22:43:11 +08:00
|
|
|
* Cordova plugin to prevent the app from going to sleep while in background.
|
|
|
|
* For more info about plugin, vist: https://github.com/katzer/cordova-plugin-background-mode#android-customization
|
2016-06-08 22:25:24 +08:00
|
|
|
*/
|
|
|
|
@Plugin({
|
2016-06-09 09:30:41 +08:00
|
|
|
plugin: 'de.appplant.cordova.plugin.background-mode',
|
|
|
|
pluginRef: 'cordova.plugins.backgroundMode',
|
2016-06-08 22:25:24 +08:00
|
|
|
repo: 'https://github.com/katzer/cordova-plugin-background-mode',
|
|
|
|
platforms: ['Android', 'iOS', 'Windows Phone 8']
|
|
|
|
})
|
|
|
|
export class BackgroundMode {
|
2016-06-08 22:43:11 +08:00
|
|
|
/**
|
|
|
|
* Enable the background mode.
|
|
|
|
* Once called, prevents the app from being puased while in background.
|
|
|
|
*/
|
2016-06-08 22:25:24 +08:00
|
|
|
@Cordova({
|
|
|
|
sync: true
|
|
|
|
})
|
|
|
|
static enable(): void{}
|
|
|
|
|
2016-06-08 22:43:11 +08:00
|
|
|
/**
|
|
|
|
* Disable the background mode.
|
|
|
|
* Once the background mode has been disabled, the app will be paused when in background.
|
|
|
|
*/
|
2016-06-08 22:25:24 +08:00
|
|
|
@Cordova()
|
|
|
|
static disable(): void{}
|
|
|
|
|
2016-06-08 22:43:11 +08:00
|
|
|
/**
|
|
|
|
* Checks if background mode is enabled or not.
|
|
|
|
*/
|
2016-06-08 22:25:24 +08:00
|
|
|
@Cordova()
|
|
|
|
static isEnabled(): Promise<boolean> {return; }
|
2016-06-08 22:43:11 +08:00
|
|
|
/**
|
|
|
|
* Can be used to get the information if the background mode is active.
|
|
|
|
*/
|
2016-06-08 22:25:24 +08:00
|
|
|
@Cordova()
|
|
|
|
static isActive(): Promise<boolean> {return; }
|
|
|
|
|
2016-06-08 22:43:11 +08:00
|
|
|
/**
|
|
|
|
* Override the default title, ticker and text.
|
|
|
|
* Available only for Android platform.
|
|
|
|
*/
|
2016-06-08 22:25:24 +08:00
|
|
|
@Cordova()
|
|
|
|
static setDefaults(options?:Defaults):void{}
|
|
|
|
|
2016-06-08 22:43:11 +08:00
|
|
|
/**
|
|
|
|
* Modify the displayed information.
|
|
|
|
* Available only for Android platform.
|
|
|
|
*/
|
2016-06-08 22:25:24 +08:00
|
|
|
@Cordova()
|
2016-06-08 22:43:11 +08:00
|
|
|
static update(options?:Configure):void{}
|
2016-06-08 22:25:24 +08:00
|
|
|
/**
|
|
|
|
* Sets a callback for a specific event
|
2016-06-08 22:43:11 +08:00
|
|
|
* Can be used to get notified or run function when the background mode has been activated, deactivated or failed.
|
2016-06-08 22:25:24 +08:00
|
|
|
* @param eventName The name of the event. Available events: activate, deactivate, failure
|
|
|
|
*/
|
|
|
|
@Cordova({
|
|
|
|
sync: true
|
|
|
|
})
|
|
|
|
static on(eventName: string, callback: any): void {}
|
|
|
|
}
|
|
|
|
/**
|
2016-06-08 22:43:11 +08:00
|
|
|
*Default configurations avaialable only on Android
|
2016-06-08 22:25:24 +08:00
|
|
|
*/
|
|
|
|
export interface Defaults{
|
|
|
|
/**
|
|
|
|
*Title of the background task
|
|
|
|
*/
|
|
|
|
title?: String;
|
|
|
|
|
|
|
|
/**
|
|
|
|
*The text that scrolls itself on statusbar
|
|
|
|
*/
|
|
|
|
ticker?: String;
|
|
|
|
|
|
|
|
/**
|
|
|
|
*Description of background task
|
|
|
|
*/
|
|
|
|
text?: String;
|
|
|
|
|
|
|
|
}
|
2016-06-08 22:43:11 +08:00
|
|
|
/**
|
|
|
|
* Configurations items that can be updated.
|
|
|
|
*/
|
2016-06-08 22:25:24 +08:00
|
|
|
export interface Configure{
|
|
|
|
/**
|
|
|
|
*Title of the background task
|
|
|
|
*/
|
|
|
|
title?: String;
|
|
|
|
|
|
|
|
/**
|
|
|
|
*The text that scrolls itself on statusbar
|
|
|
|
*/
|
|
|
|
ticker?: String;
|
|
|
|
|
|
|
|
/**
|
|
|
|
*Description of background task
|
|
|
|
*/
|
|
|
|
text?: String;
|
|
|
|
|
|
|
|
/**
|
|
|
|
*Boolean, if true plugin will not display a notification. Default is false.
|
|
|
|
*/
|
|
|
|
silent?:boolean;
|
|
|
|
|
|
|
|
}
|