cordova-plugin-sms
cordova-plugin-sms copied to clipboard
deleteSMS doesn't work
SMS.deleteSMS({box: '', address: gate_address}, function(n) { alert(n + ' sms messages deleted'); }, function(err){ alert('error delete sms: ' + err); });
showing "X sms messages deleted" and nothing ((
Android 4.4.2
What is X in the message? And address filter should be the sent phone number, what is gate_address here?
Ok...
var gate_address = '+79050850161';
CleanupSMS: function () {
alert(gate_address);
SMS.deleteSMS({box: '', address: gate_address}, function(n) {
alert(n + ' sms messages deleted');
}, function(err){
alert('error delete sms: ' + err);
});
},
first screenshot: gate_address is 79050850161

second screenshot: no error, 5 messages should be deleted

third screenshot: all messages at their places ((

I tested all APIs on my samsung s4 (android 4.3) and it worked pretty well.
but not tested on android 4.4 device yet.
looks like kitkat has some changes in sms
http://android-developers.blogspot.ru/2013/10/getting-your-sms-apps-ready-for-kitkat.html
Yeah, you are right. I know that access to SMS has been restricted since 4.4.
I remember that it's not allowed to intercept SMS any more, but not sure that deleting is not allowed either...
@floatinghotpot i tried this pluging on android 4.1.2 and the delete failed !!! any help ?? the listSMS worked fine that mean the plugin is ok , but the delete do nothing.
$scope.delete = function(id) {
console.log("id = " + id); if(SMS) SMS.deleteSMS({ _id : id }, function( n ){ console.log( n + ' sms messages deleted' ); }, function(err){ console.log('error delete sms: ' + err); });
any help ?
update: the error i get
java.lang.IllegalArgumentException: Uknown URL
I obtain the same error on Android 4.1.2
On android 5 work without error but not delete nothing, the list work fine
i found a fix you must change on SMSPlugin.java
ctx.getContentResolver().delete(uri, "_id=" + id, (String[])null);
to
ctx.getContentResolver().delete(Uri.parse("content://sms/" + id),null, (String[])null);
@trippo , did it work fine for you?
Yes on android 4.1.2
As to intercept / delete, it depends on the Android OS version. It’s quite okay on version before Android 4.4+.
But after v4.4, as Google add very strict security control after v4.4, and only the system default SMS app can intercept / delete SMS.
If your app is not the default SMS app, you can still get & read SMS, but cannot intercept / delete (remove SMS before other app get it) any more.
Yes i +1 this delete and intercept is not working anymore on devices >4.4. Still can read messages and setup alerts on sms arrival.
This still seems to be the case.
For me it not working? any solution?