Security Exception when sending SMS using cordova in android 7.0

I am trying to send sms from a device using the sms manager by adding the corodova send sms plugin. This application works fine until the android6.0 device sends sms, but when I tried to send sms from android7.0, it shows me the following security exception. Before sending sms, he asks for permission, and I also gave permission.

An exception:

java.lang.SecurityException: at android.os.Parcel.readException(Parcel.java:1683) at android.os.Parcel.readException(Parcel.java:1636) at com.android.internal.telephony.IPhoneSubInfo$Stub$Proxy.getGroupIdLevel1(IPhoneSubInfo.java:583) at android.telephony.TelephonyManager.getGroupIdLevel1(TelephonyManager.java:2163) at android.telephony.SmsMessage.hasEmsSupport(SmsMessage.java:854) at com.android.internal.telephony.SmsMessageBase.calcUnicodeEncodingDetails(SmsMessageBase.java:409) at com.android.internal.telephony.gsm.SmsMessage.calculateLength(SmsMessage.java:796) at android.telephony.SmsMessage.fragmentText(SmsMessage.java:354) at android.telephony.SmsManager.divideMessage(SmsManager.java:450) at com.cordova.plugins.sms.Sms.send(Sms.java:143) at com.cordova.plugins.sms.Sms.access$400(Sms.java:22) at com.cordova.plugins.sms.Sms$1.run(Sms.java:102) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:761) 

Code for sending SMS:

  var smsdata = ' தேதி: ' + this.currentbilldate + ' பில் எண்: ' + this.save_details.vehicle_bill_no + ' எடுக்கப்பட்ட பொருட்களின் விவரங்கள்: ' + this.smselements.toString() + ', மொத்த பொருட்கள்: ' + totalcount + ''; var farmermobileno = this.entry_details.farmer_mobile_no; this.sms.send(farmermobileno, smsdata).then((result) => { this.commonService.presentToast('Message sent successfully'); }, (error) => { console.log('Error in sending message', error); this.commonService.presentToast('Message Failed'); }); 

Plugin name: Cordova-sms-plugin

Sending text to SMS:

  var smsdata = 'உங்கள் கணக்கில் அன்று 23-8-17 அட்வான்ஸ் தொகை ₹500 வழங்கப்பட்டுள்ளது.இருப்பு ₹5000'; 
+7
android cordova ionic3
source share
1 answer

Hope you can use the method below to check permissions.

On Android, an additional function you can find out if you know you have permission to send SMS (permission Android Marshmallow).

 var app = { checkSMSPermission: function() { var success = function (hasPermission) { if (hasPermission) { sms.send(...); } else { // show a helpful message to explain why you need to require the permission to send a SMS // read http://developer.android.com/training/permissions/requesting.html#explain for more best practices } }; var error = function (e) { alert('Something went wrong:' + e); }; sms.hasPermission(success, error); } }; 

More details can be found here. Git .

Update:

 var smsdata = 'உங்கள் கணக்கில் அன்று 23-8-17 அட்வான்ஸ் தொகை' + '₹500' + 'வழங்கப்பட்டுள்ளது.இருப்பு'+ '₹5000'; 
+2
source share

All Articles