diff --git a/README.md b/README.md index 8f5abd8..6c02a41 100644 --- a/README.md +++ b/README.md @@ -91,3 +91,28 @@ phone.sms(["212-555-1234","212-555-1245"],"My Message") } ); ``` + + +### TypeScript example + +```TypeScript + +import * as TNSPhone from 'nativescript-phone'; + +/// Dial a phone number. +public callHome() { + TNSPhone.dial('415-123-4567', false); +} + +// Text a number (or multiple numbers) +public messageParents() { + TNSPhone.sms(['212-555-1234', '212-555-0987'], "Text till your fingers bleed") + .then((args) => { + console.log(JSON.stringify(args)); + }, (err) => { + console.log('Error: ' + err); + }) +} + + +``` diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..ed27596 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,21 @@ +/** + * Initiate a phone call. + * @param {string} number - The number to dial. + * @param {boolean} confirm - To enable OS specific confirmation before dialing. + */ +export function dial(number: string, confirm: boolean); + + +/** + * Open the OS specific SMS app. + * @param {Array} numbers - The number to send SMS to. + * @param {string} message - The message to send. + */ +export function sms(numbers: Array, message: string): Promise; + + +interface response { + "success": string, + "cancelled": string, + "failed": string +} \ No newline at end of file diff --git a/package.json b/package.json index 2e3e739..f3e7a09 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "1.1.0", "description": "A phone NativeScript module for Android and iOS", "main": "index.js", + "typings": "index.d.ts", "repository": { "type": "git", "url": "https://github.com/msywensky/nativescript-phone.git" @@ -11,6 +12,13 @@ "NativeScript" ], "author": "Mike Sywensky ", + "contributors": [ + { + "name": "Brad Martin", + "email": " bradwaynemartin@gmail.com", + "url": "https://github.com/bradmartin" + } + ], "license": { "type": "MIT", "url": "https://github.com/msywensky/nativescript-phone/blob/master/LICENSE" @@ -25,4 +33,4 @@ "ios": "1.0.0" } } -} +} \ No newline at end of file