2016-02-17 17:36:38 +08:00
|
|
|
|
import {Plugin, Cordova} from './plugin';
|
|
|
|
|
|
|
|
|
|
/**
|
2016-03-13 07:30:16 +08:00
|
|
|
|
* @name Badge
|
|
|
|
|
* @description
|
2016-02-17 17:36:38 +08:00
|
|
|
|
* The essential purpose of badge numbers is to enable an application to inform its users that it has something for them — for example, unread messages — when the application isn’t running in the foreground.
|
|
|
|
|
*
|
2016-03-05 05:42:21 +08:00
|
|
|
|
* Requires Cordova plugin: cordova-plugin-badge. For more info, please see the [Badge plugin docs](https://github.com/katzer/cordova-plugin-badge).
|
2016-02-17 17:36:38 +08:00
|
|
|
|
*
|
|
|
|
|
* @usage
|
|
|
|
|
* ```js
|
2016-03-25 01:00:18 +08:00
|
|
|
|
* import {Badge} from 'ionic-native';
|
|
|
|
|
*
|
|
|
|
|
*
|
2016-03-05 05:42:21 +08:00
|
|
|
|
* Badge.set(10);
|
|
|
|
|
* Badge.increase();
|
|
|
|
|
* Badge.clear();
|
2016-02-17 17:36:38 +08:00
|
|
|
|
* ```
|
|
|
|
|
*/
|
|
|
|
|
@Plugin({
|
|
|
|
|
plugin: 'cordova-plugin-badge',
|
2016-03-13 08:08:47 +08:00
|
|
|
|
pluginRef: 'cordova.plugins.notification.badge',
|
2016-03-15 01:38:35 +08:00
|
|
|
|
repo: 'https://github.com/katzer/cordova-plugin-badge',
|
|
|
|
|
platforms: ['Android', 'iOS', 'Browser', 'Windows', 'Amazon FireOS', 'Windows Phone 8']
|
2016-02-17 17:36:38 +08:00
|
|
|
|
})
|
|
|
|
|
export class Badge {
|
|
|
|
|
|
|
|
|
|
/**
|
2016-03-05 05:42:21 +08:00
|
|
|
|
* Clear the badge of the app icon.
|
2016-02-17 17:36:38 +08:00
|
|
|
|
*/
|
|
|
|
|
@Cordova()
|
2016-04-30 11:56:49 +08:00
|
|
|
|
static clear(): Promise<boolean> { return; }
|
2016-02-17 17:36:38 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2016-03-05 05:42:21 +08:00
|
|
|
|
* Set the badge of the app icon.
|
2016-04-30 11:56:49 +08:00
|
|
|
|
* @param {number} badgeNumber The new badge number.
|
2016-03-05 05:42:21 +08:00
|
|
|
|
* @returns {Promise}
|
2016-02-17 17:36:38 +08:00
|
|
|
|
*/
|
|
|
|
|
@Cordova()
|
2016-04-30 11:56:49 +08:00
|
|
|
|
static set(badgeNumber: number): Promise<any> { return; }
|
2016-02-17 17:36:38 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2016-03-05 05:42:21 +08:00
|
|
|
|
* Get the badge of the app icon.
|
|
|
|
|
* @returns {Promise}
|
2016-02-17 17:36:38 +08:00
|
|
|
|
*/
|
|
|
|
|
@Cordova()
|
2016-04-30 11:56:49 +08:00
|
|
|
|
static get(): Promise<any> { return; }
|
2016-02-17 17:36:38 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2016-03-05 05:42:21 +08:00
|
|
|
|
* Increase the badge number.
|
2016-04-30 11:56:49 +08:00
|
|
|
|
* @param {number} increaseBy Count to add to the current badge number
|
2016-03-05 05:42:21 +08:00
|
|
|
|
* @returns {Promise}
|
2016-02-17 17:36:38 +08:00
|
|
|
|
*/
|
|
|
|
|
@Cordova()
|
2016-04-30 11:56:49 +08:00
|
|
|
|
static increase(increaseBy: number): Promise<any> { return; }
|
2016-02-17 17:36:38 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2016-03-05 05:42:21 +08:00
|
|
|
|
* Decrease the badge number.
|
2016-04-30 11:56:49 +08:00
|
|
|
|
* @param {number} decreaseBy Count to subtract from the current badge number
|
2016-03-05 05:42:21 +08:00
|
|
|
|
* @returns {Promise}
|
2016-02-17 17:36:38 +08:00
|
|
|
|
*/
|
|
|
|
|
@Cordova()
|
2016-04-30 11:56:49 +08:00
|
|
|
|
static decrease(decreaseBy: number): Promise<any> { return; }
|
2016-02-17 17:36:38 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2016-03-05 05:42:21 +08:00
|
|
|
|
* Determine if the app has permission to show badges.
|
2016-02-17 17:36:38 +08:00
|
|
|
|
*/
|
|
|
|
|
@Cordova()
|
2016-04-30 11:56:49 +08:00
|
|
|
|
static hasPermission(): Promise<any> { return; }
|
2016-02-17 17:36:38 +08:00
|
|
|
|
|
2016-03-05 05:42:21 +08:00
|
|
|
|
/**
|
|
|
|
|
* Register permission to set badge notifications
|
|
|
|
|
* @returns {Promise}
|
|
|
|
|
*/
|
|
|
|
|
@Cordova()
|
2016-04-30 11:56:49 +08:00
|
|
|
|
static registerPermission(): Promise<any> { return; }
|
2016-02-17 17:36:38 +08:00
|
|
|
|
}
|