2017-03-20 16:38:14 -04:00
import { Injectable } from '@angular/core' ;
2017-12-28 07:28:44 -05:00
import { Cordova , IonicNativePlugin , Plugin } from '@ionic-native/core' ;
2017-03-20 16:38:14 -04:00
2016-02-17 04:36:38 -05:00
/**
2016-03-12 18:30:16 -05:00
* @name Badge
* @description
2016-02-17 04:36:38 -05: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-04 15:42:21 -06: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 04:36:38 -05:00
*
* @usage
2016-07-20 17:17:09 +02:00
* ```typescript
2018-10-10 16:13:45 -05:00
* import { Badge } from '@ionic-native/badge/ngx';
2017-03-20 16:38:14 -04:00
*
* constructor(private badge: Badge) { }
2016-03-24 13:00:18 -04:00
*
2017-03-20 16:38:14 -04:00
* ...
2016-03-24 13:00:18 -04:00
*
2017-03-20 16:38:14 -04:00
* this.badge.set(10);
* this.badge.increase(1);
* this.badge.clear();
2016-02-17 04:36:38 -05:00
* ```
*/
@Plugin ( {
2016-10-27 12:48:50 -05:00
pluginName : 'Badge' ,
2016-02-17 04:36:38 -05:00
plugin : 'cordova-plugin-badge' ,
2016-03-12 19:08:47 -05:00
pluginRef : 'cordova.plugins.notification.badge' ,
2016-03-14 13:38:35 -04:00
repo : 'https://github.com/katzer/cordova-plugin-badge' ,
2017-06-02 21:34:18 +02:00
platforms : [ 'Android' , 'Browser' , 'iOS' , 'Windows' ]
2016-02-17 04:36:38 -05:00
} )
2019-02-20 17:37:39 +01:00
@Injectable ( {
providedIn : 'root'
} )
2017-04-27 00:36:12 -04:00
export class Badge extends IonicNativePlugin {
2016-02-17 04:36:38 -05:00
/**
2016-03-04 15:42:21 -06:00
* Clear the badge of the app icon.
2016-11-29 16:40:50 -06:00
* @returns {Promise<boolean>}
2016-02-17 04:36:38 -05:00
*/
@Cordova ( )
2017-12-28 07:28:44 -05:00
clear ( ) : Promise < boolean > {
return ;
}
2016-02-17 04:36:38 -05:00
/**
2016-03-04 15:42:21 -06:00
* Set the badge of the app icon.
2016-04-29 23:56:49 -04:00
* @param {number} badgeNumber The new badge number.
2016-11-29 16:40:50 -06:00
* @returns {Promise<any>}
2016-02-17 04:36:38 -05:00
*/
@Cordova ( )
2017-12-28 07:28:44 -05:00
set ( badgeNumber : number ) : Promise < any > {
return ;
}
2016-02-17 04:36:38 -05:00
/**
2016-03-04 15:42:21 -06:00
* Get the badge of the app icon.
2016-11-29 16:40:50 -06:00
* @returns {Promise<any>}
2016-02-17 04:36:38 -05:00
*/
@Cordova ( )
2017-12-28 07:28:44 -05:00
get ( ) : Promise < any > {
return ;
}
2016-02-17 04:36:38 -05:00
/**
2016-03-04 15:42:21 -06:00
* Increase the badge number.
2016-04-29 23:56:49 -04:00
* @param {number} increaseBy Count to add to the current badge number
2016-11-29 16:40:50 -06:00
* @returns {Promise<any>}
2016-02-17 04:36:38 -05:00
*/
@Cordova ( )
2017-12-28 07:28:44 -05:00
increase ( increaseBy : number ) : Promise < any > {
return ;
}
2016-02-17 04:36:38 -05:00
/**
2016-03-04 15:42:21 -06:00
* Decrease the badge number.
2016-04-29 23:56:49 -04:00
* @param {number} decreaseBy Count to subtract from the current badge number
2016-11-29 16:40:50 -06:00
* @returns {Promise<any>}
2016-02-17 04:36:38 -05:00
*/
@Cordova ( )
2017-12-28 07:28:44 -05:00
decrease ( decreaseBy : number ) : Promise < any > {
return ;
}
2016-02-17 04:36:38 -05:00
2018-03-15 18:02:35 +01:00
/**
* Check support to show badges.
* @returns {Promise<any>}
*/
@Cordova ( )
2018-03-15 18:06:25 +01:00
isSupported ( ) : Promise < any > {
return ;
}
2016-02-17 04:36:38 -05:00
/**
2016-03-04 15:42:21 -06:00
* Determine if the app has permission to show badges.
2016-11-29 16:40:50 -06:00
* @returns {Promise<any>}
2016-02-17 04:36:38 -05:00
*/
@Cordova ( )
2017-12-28 07:28:44 -05:00
hasPermission ( ) : Promise < any > {
return ;
}
2016-02-17 04:36:38 -05:00
2016-03-04 15:42:21 -06:00
/**
* Register permission to set badge notifications
2016-11-29 16:40:50 -06:00
* @returns {Promise<any>}
2016-03-04 15:42:21 -06:00
*/
@Cordova ( )
2018-03-17 10:38:05 +01:00
requestPermission ( ) : Promise < any > {
2017-12-28 07:28:44 -05:00
return ;
}
2016-02-17 04:36:38 -05:00
}