diff --git a/types/cordova-universal-links-plugin/cordova-universal-links-plugin-tests.ts b/types/cordova-universal-links-plugin/cordova-universal-links-plugin-tests.ts new file mode 100644 index 0000000000..1a6981b2e9 --- /dev/null +++ b/types/cordova-universal-links-plugin/cordova-universal-links-plugin-tests.ts @@ -0,0 +1,16 @@ +const newsEventname = 'openNewsListPage'; +universalLinks.subscribe(newsEventname, onNewsListPageRequested); + +function onNewsListPageRequested(eventData: universalLinks.EventData) { + alert('Did launch application with news link: ' + eventData.url); +} + +universalLinks.unsubscribe('openNewsListPage'); + +universalLinks.subscribe(null, onOtherLinkRequested); + +function onOtherLinkRequested(eventData: universalLinks.EventData) { + alert('Did launch application with other link: ' + eventData.url); +} + +universalLinks.unsubscribe(null); diff --git a/types/cordova-universal-links-plugin/index.d.ts b/types/cordova-universal-links-plugin/index.d.ts new file mode 100644 index 0000000000..98217a1b0a --- /dev/null +++ b/types/cordova-universal-links-plugin/index.d.ts @@ -0,0 +1,18 @@ +// Type definitions for cordova-universal-links-plugin 1.2 +// Project: https://github.com/nordnet/cordova-universal-links-plugin#readme +// Definitions by: David Broder-Rodgers +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace universalLinks { + function subscribe(eventName: string | null, callback: (data: EventData) => void): void; + function unsubscribe(eventName: string | null): void; + + interface EventData { + url: string; + scheme: string; + host: string; + path: string; + params: { [key: string]: string }; + hash: string; + } +} diff --git a/types/cordova-universal-links-plugin/tsconfig.json b/types/cordova-universal-links-plugin/tsconfig.json new file mode 100644 index 0000000000..69322a9265 --- /dev/null +++ b/types/cordova-universal-links-plugin/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "cordova-universal-links-plugin-tests.ts" + ] +} diff --git a/types/cordova-universal-links-plugin/tslint.json b/types/cordova-universal-links-plugin/tslint.json new file mode 100644 index 0000000000..d88586e5bd --- /dev/null +++ b/types/cordova-universal-links-plugin/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +}