diff --git a/types/cordova-plugin-badge/cordova-plugin-badge-tests.ts b/types/cordova-plugin-badge/cordova-plugin-badge-tests.ts new file mode 100644 index 0000000000..453b27d884 --- /dev/null +++ b/types/cordova-plugin-badge/cordova-plugin-badge-tests.ts @@ -0,0 +1,16 @@ +/// + +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 +}); diff --git a/types/cordova-plugin-badge/index.d.ts b/types/cordova-plugin-badge/index.d.ts new file mode 100644 index 0000000000..6b4e780d5f --- /dev/null +++ b/types/cordova-plugin-badge/index.d.ts @@ -0,0 +1,25 @@ +// Type definitions for cordova-plugin-badge 0.8 +// Project: https://github.com/katzer/cordova-plugin-badge +// Definitions by: Tim Brust +// 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; +} diff --git a/types/cordova-plugin-badge/tsconfig.json b/types/cordova-plugin-badge/tsconfig.json new file mode 100644 index 0000000000..5f6a71f137 --- /dev/null +++ b/types/cordova-plugin-badge/tsconfig.json @@ -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" + ] +} diff --git a/types/cordova-plugin-badge/tslint.json b/types/cordova-plugin-badge/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/cordova-plugin-badge/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }