Skip to content

Commit db06d3f

Browse files
committed
missing require
1 parent b8232a8 commit db06d3f

File tree

3 files changed

+69
-73
lines changed

3 files changed

+69
-73
lines changed

index.android.js

Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,59 @@
11
var application = require("application");
22

3-
function dial(telNum,prompt) {
3+
function dial(telNum, prompt) {
44

5-
try {
6-
var intentType = android.content.Intent.ACTION_CALL;
7-
if (prompt) {
8-
intentType = android.content.Intent.ACTION_DIAL
9-
}
5+
try {
6+
var intentType = android.content.Intent.ACTION_CALL;
7+
if (prompt) {
8+
intentType = android.content.Intent.ACTION_DIAL
9+
}
1010

11-
var intent = new android.content.Intent(intentType);
11+
var intent = new android.content.Intent(intentType);
1212

13-
//support for ussd numbers with # on android
14-
telNum = telNum.replace('#', encodeURIComponent('#'));
13+
//support for ussd numbers with # on android
14+
telNum = telNum.replace('#', encodeURIComponent('#'));
1515

16-
intent.setData(android.net.Uri.parse("tel:" + telNum));
16+
intent.setData(android.net.Uri.parse("tel:" + telNum));
1717

18-
application.android.foregroundActivity.startActivity(intent);
19-
return true;
18+
application.android.foregroundActivity.startActivity(intent);
19+
return true;
2020

21-
} catch(ex) {
22-
//alert("Unable to dial");
23-
//console.log("phone.dial failed: " + ex);
24-
return false;
25-
}
21+
} catch (ex) {
22+
//alert("Unable to dial");
23+
//console.log("phone.dial failed: " + ex);
24+
return false;
25+
}
2626
}
2727

2828
function sms(smsNum, messageText) {
29-
return new Promise(function (resolve, reject){
30-
if(!Array.isArray(smsNum)){
29+
return new Promise(function (resolve, reject) {
30+
if (!Array.isArray(smsNum)) {
3131
smsNum = [smsNum];
3232
}
33-
34-
try {
33+
34+
try {
3535
var SEND_SMS = 1001;
36-
var intent = new android.content.Intent(android.content.Intent.ACTION_VIEW);
36+
var intent = new android.content.Intent(android.content.Intent.ACTION_VIEW);
3737
intent.putExtra("address", smsNum.join(";"));
38-
intent.putExtra("sms_body", messageText);
38+
intent.putExtra("sms_body", messageText);
3939
intent.setType("vnd.android-dir/mms-sms");
40-
40+
4141
var previousResult = application.android.onActivityResult;
42-
application.android.onActivityResult = function(requestCode, resultCode, data) {
42+
application.android.onActivityResult = function (requestCode, resultCode, data) {
4343
switch (requestCode) {
44-
case SEND_SMS:
44+
case SEND_SMS:
4545
application.android.onActivityResult = previousResult;
46-
if (resultCode === android.app.Activity.RESULT_OK){
46+
if (resultCode === android.app.Activity.RESULT_OK) {
4747
return resolve({
48-
response:"success"
48+
response: "success"
4949
});
50-
}
51-
else if (resultCode === android.app.Activity.RESULT_CANCELED){
50+
} else if (resultCode === android.app.Activity.RESULT_CANCELED) {
5251
return resolve({
53-
response:"cancelled"
52+
response: "cancelled"
5453
});
55-
}
56-
else {
54+
} else {
5755
return resolve({
58-
response:"failed"
56+
response: "failed"
5957
});
6058
}
6159
break;
@@ -67,11 +65,11 @@ function sms(smsNum, messageText) {
6765
}
6866
};
6967
application.android.foregroundActivity.startActivityForResult(intent, SEND_SMS);
70-
} catch(ex) {
68+
} catch (ex) {
7169
reject(ex.toString());
72-
}
70+
}
7371
});
7472
}
7573

7674
exports.dial = dial;
77-
exports.sms = sms;
75+
exports.sms = sms;

index.ios.js

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
11
var frameModule = require("ui/frame");
2+
var utils = require("utils/utils");
23

3-
var CustomMFMessageComposeViewControllerDelegate = NSObject.extend({
4-
initWithResolveReject: function(resolve, reject) {
4+
var CustomMFMessageComposeViewControllerDelegate = NSObject.extend({
5+
initWithResolveReject: function (resolve, reject) {
56
var self = this.super.init();
6-
if(self) {
7+
if (self) {
78
this.resolve = resolve;
89
this.reject = reject;
910
}
1011
return self;
1112
},
12-
messageComposeViewControllerDidFinishWithResult: function(controller, result){
13+
messageComposeViewControllerDidFinishWithResult: function (controller, result) {
1314
controller.dismissModalViewControllerAnimated(true);
14-
15-
if(result === MessageComposeResultCancelled){
15+
16+
if (result === MessageComposeResultCancelled) {
1617
this.resolve({
17-
response:"cancelled"
18+
response: "cancelled"
1819
});
19-
}
20-
else if(result === MessageComposeResultSent){
20+
} else if (result === MessageComposeResultSent) {
2121
this.resolve({
22-
response:"success"
22+
response: "success"
2323
});
24-
}
25-
else{
24+
} else {
2625
this.resolve({
27-
response:"failed"
26+
response: "failed"
2827
});
2928
}
3029
CFRelease(controller.messageComposeDelegate);
@@ -34,48 +33,47 @@ var CustomMFMessageComposeViewControllerDelegate = NSObject.extend({
3433
protocols: [MFMessageComposeViewControllerDelegate]
3534
});
3635

37-
function dial(telNum,prompt) {
38-
var sURL = "tel://";
36+
function dial(telNum, prompt) {
37+
var sURL = "tel://";
3938

40-
if (prompt) {
41-
sURL = "telprompt:";
42-
}
39+
if (prompt) {
40+
sURL = "telprompt:";
41+
}
4342

44-
var url = NSURL.URLWithString(sURL + telNum);
43+
var url = NSURL.URLWithString(sURL + telNum);
4544

46-
if(utils.ios.getter(UIApplication, UIApplication.sharedApplication).canOpenURL(url)){
47-
utils.ios.getter(UIApplication, UIApplication.sharedApplication).openURL(url);
48-
return true;
49-
} else {
50-
//alert("Unable to dial");
51-
return false;
52-
}
45+
if (utils.ios.getter(UIApplication, UIApplication.sharedApplication).canOpenURL(url)) {
46+
utils.ios.getter(UIApplication, UIApplication.sharedApplication).openURL(url);
47+
return true;
48+
} else {
49+
//alert("Unable to dial");
50+
return false;
51+
}
5352

5453
}
5554

5655
function sms(smsNum, messageText) {
57-
return new Promise(function (resolve, reject){
58-
if(!Array.isArray(smsNum)){
56+
return new Promise(function (resolve, reject) {
57+
if (!Array.isArray(smsNum)) {
5958
smsNum = [smsNum];
6059
}
61-
60+
6261
var page = frameModule.topmost().ios.controller;
6362
var controller = MFMessageComposeViewController.alloc().init();
6463
var delegate = CustomMFMessageComposeViewControllerDelegate.alloc().initWithResolveReject(resolve, reject);
65-
64+
6665
CFRetain(delegate);
6766
controller.messageComposeDelegate = delegate;
68-
69-
if(MFMessageComposeViewController.canSendText()){
67+
68+
if (MFMessageComposeViewController.canSendText()) {
7069
controller.body = messageText;
7170
controller.recipients = smsNum;
7271
page.presentModalViewControllerAnimated(controller, true);
73-
}
74-
else{
72+
} else {
7573
reject("Cannot Send SMS!");
7674
}
7775
});
7876
}
7977

8078
exports.dial = dial;
81-
exports.sms = sms;
79+
exports.sms = sms;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-phone",
3-
"version": "1.2.2",
3+
"version": "1.2.3",
44
"description": "NativeScript plugin to use the device phone and SMS features for Android and iOS",
55
"main": "index.js",
66
"typings": "index.d.ts",

0 commit comments

Comments
 (0)