Merge pull request #17711 from timbru31/feat/cordova-plugin-badge

feat(cordova-plugin-badge): add typings for cordova-plugin-badge
This commit is contained in:
Ron Buckton
2017-07-06 16:35:58 -07:00
committed by GitHub
4 changed files with 65 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
/// <reference types="cordova" />
function callback(badgeOrGranted: number | boolean) {
console.log(badgeOrGranted);
}
window.cordova.plugins.notification.badge.clear();
window.cordova.plugins.notification.badge.set(10, callback);
window.cordova.plugins.notification.badge.decrease(2, callback);
window.cordova.plugins.notification.badge.increase(5, callback);
window.cordova.plugins.notification.badge.hasPermission(callback);
window.cordova.plugins.notification.badge.requestPermission(callback);
window.cordova.plugins.notification.badge.get(callback);
window.cordova.plugins.notification.badge.configure({
autoClear: true
});

25
types/cordova-plugin-badge/index.d.ts vendored Normal file
View File

@@ -0,0 +1,25 @@
// Type definitions for cordova-plugin-badge 0.8
// Project: https://github.com/katzer/cordova-plugin-badge
// Definitions by: Tim Brust <https://github.com/timbru31>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface CordovaPlugins {
notification: {
badge: CordovaPluginBadge;
};
}
interface CordovaPluginBadgeOptions {
autoClear: boolean;
}
interface CordovaPluginBadge {
clear(callback?: (badge: number) => void, scope?: any): void;
set(badge?: number, callback?: (badge: number) => void, scope?: any): void;
get(callback?: (badge: number) => void, scope?: any): void;
increase(count?: number, callback?: (badge: number) => void, scope?: any): void;
decrease(count?: number, callback?: (badge: number) => void, scope?: any): void;
hasPermission(callback?: (granted: boolean) => void, scope?: any): void;
requestPermission(callback?: (granted: boolean) => void, scope?: any): void;
configure(config: CordovaPluginBadgeOptions): CordovaPluginBadgeOptions;
}

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"cordova-plugin-badge-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }