Skip to content

Commit

Permalink
Merge pull request #12 from bradmartin/master
Browse files Browse the repository at this point in the history
TypeScript definition/examples
  • Loading branch information
msywensky authored Sep 6, 2016
2 parents 1988d21 + a297a09 commit cf3f566
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
})
}


```
21 changes: 21 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -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<string>} numbers - The number to send SMS to.
* @param {string} message - The message to send.
*/
export function sms(numbers: Array<string>, message: string): Promise<response>;


interface response {
"success": string,
"cancelled": string,
"failed": string
}
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -11,6 +12,13 @@
"NativeScript"
],
"author": "Mike Sywensky <[email protected]> ",
"contributors": [
{
"name": "Brad Martin",
"email": " [email protected]",
"url": "https://github.com/bradmartin"
}
],
"license": {
"type": "MIT",
"url": "https://github.com/msywensky/nativescript-phone/blob/master/LICENSE"
Expand All @@ -25,4 +33,4 @@
"ios": "1.0.0"
}
}
}
}

0 comments on commit cf3f566

Please sign in to comment.