@@ -27,6 +27,7 @@ public class Sms extends CordovaPlugin {
2727
2828 @ Override
2929 public boolean execute (String action , JSONArray args , final CallbackContext callbackContext ) throws JSONException {
30+
3031 if (action .equals (ACTION_SEND_SMS )) {
3132 try {
3233 String phoneNumber = args .getJSONArray (0 ).join (";" ).replace ("\" " , "" );
@@ -43,34 +44,34 @@ public boolean execute(String action, JSONArray args, final CallbackContext call
4344 // always passes success back to the app
4445 callbackContext .sendPluginResult (new PluginResult (PluginResult .Status .OK ));
4546 } else {
46- // by creating this broadcast receiver we can check whether or not the SMS was sent
47+ // by creating this broadcast receiver we can check whether or not the SMS was sent
4748 if (receiver == null ) {
4849 this .receiver = new BroadcastReceiver () {
4950 @ Override
5051 public void onReceive (Context context , Intent intent ) {
5152 PluginResult pluginResult ;
5253
5354 switch (getResultCode ()) {
54- case SmsManager .STATUS_ON_ICC_SENT :
55- pluginResult = new PluginResult (PluginResult .Status .OK );
56- pluginResult .setKeepCallback (true );
57- callbackContext .sendPluginResult (pluginResult );
58- break ;
59- case Activity .RESULT_OK :
60- pluginResult = new PluginResult (PluginResult .Status .OK );
61- pluginResult .setKeepCallback (true );
62- callbackContext .sendPluginResult (pluginResult );
63- break ;
64- case SmsManager .RESULT_ERROR_NO_SERVICE :
65- pluginResult = new PluginResult (PluginResult .Status .ERROR );
66- pluginResult .setKeepCallback (true );
67- callbackContext .sendPluginResult (pluginResult );
68- break ;
69- default :
70- pluginResult = new PluginResult (PluginResult .Status .ERROR );
71- pluginResult .setKeepCallback (true );
72- callbackContext .sendPluginResult (pluginResult );
73- break ;
55+ case SmsManager .STATUS_ON_ICC_SENT :
56+ pluginResult = new PluginResult (PluginResult .Status .OK );
57+ pluginResult .setKeepCallback (true );
58+ callbackContext .sendPluginResult (pluginResult );
59+ break ;
60+ case Activity .RESULT_OK :
61+ pluginResult = new PluginResult (PluginResult .Status .OK );
62+ pluginResult .setKeepCallback (true );
63+ callbackContext .sendPluginResult (pluginResult );
64+ break ;
65+ case SmsManager .RESULT_ERROR_NO_SERVICE :
66+ pluginResult = new PluginResult (PluginResult .Status .ERROR );
67+ pluginResult .setKeepCallback (true );
68+ callbackContext .sendPluginResult (pluginResult );
69+ break ;
70+ default :
71+ pluginResult = new PluginResult (PluginResult .Status .ERROR );
72+ pluginResult .setKeepCallback (true );
73+ callbackContext .sendPluginResult (pluginResult );
74+ break ;
7475 }
7576 }
7677 };
@@ -90,8 +91,7 @@ public void onReceive(Context context, Intent intent) {
9091
9192 private boolean checkSupport () {
9293 Activity ctx = this .cordova .getActivity ();
93- return ctx .getPackageManager ().hasSystemFeature (
94- PackageManager .FEATURE_TELEPHONY );
94+ return ctx .getPackageManager ().hasSystemFeature (PackageManager .FEATURE_TELEPHONY );
9595 }
9696
9797 @ SuppressLint ("NewApi" )
@@ -117,7 +117,8 @@ private void invokeSMSIntent(String phoneNumber, String message) {
117117
118118 private void send (String phoneNumber , String message ) {
119119 SmsManager manager = SmsManager .getDefault ();
120- PendingIntent sentIntent = PendingIntent .getBroadcast (this .cordova .getActivity (), 0 , new Intent (INTENT_FILTER_SMS_SENT ), 0 );
120+ PendingIntent sentIntent = PendingIntent .getBroadcast (this .cordova .getActivity (),
121+ 0 , new Intent (INTENT_FILTER_SMS_SENT ), 0 );
121122
122123 // Use SendMultipartTextMessage if the message requires it
123124 int parts_size = manager .divideMessage (message ).size ();
@@ -128,9 +129,10 @@ private void send(String phoneNumber, String message) {
128129 sentIntents .add (sentIntent );
129130 }
130131 manager .sendMultipartTextMessage (phoneNumber , null , parts ,
131- sentIntents , null );
132+ sentIntents , null );
132133 } else {
133- manager .sendTextMessage (phoneNumber , null , message , sentIntent , null );
134+ manager .sendTextMessage (phoneNumber , null , message , sentIntent ,
135+ null );
134136 }
135137 }
136138
@@ -145,3 +147,4 @@ public void onDestroy() {
145147 }
146148 }
147149}
150+
0 commit comments