cordova-plugin-sms icon indicating copy to clipboard operation
cordova-plugin-sms copied to clipboard

deleteSMS doesn't work

Open mmikel opened this issue 10 years ago • 15 comments

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

mmikel avatar Feb 16 '15 12:02 mmikel

What is X in the message? And address filter should be the sent phone number, what is gate_address here?

floatinghotpot avatar Feb 17 '15 03:02 floatinghotpot

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 screenshot_2015-02-17-06-43-10

second screenshot: no error, 5 messages should be deleted screenshot_2015-02-17-06-43-17

third screenshot: all messages at their places (( screenshot_2015-02-17-06-43-35

mmikel avatar Feb 17 '15 03:02 mmikel

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.

floatinghotpot avatar Feb 21 '15 00:02 floatinghotpot

looks like kitkat has some changes in sms

http://android-developers.blogspot.ru/2013/10/getting-your-sms-apps-ready-for-kitkat.html

mmikel avatar Feb 21 '15 07:02 mmikel

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 avatar Feb 21 '15 08:02 floatinghotpot

@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

firaskudsy avatar Jul 20 '15 05:07 firaskudsy

I obtain the same error on Android 4.1.2

trippo avatar Jan 11 '16 10:01 trippo

On android 5 work without error but not delete nothing, the list work fine

trippo avatar Jan 11 '16 11:01 trippo

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 avatar Jan 11 '16 13:01 trippo

@trippo , did it work fine for you?

AlbanWende avatar Jan 26 '16 10:01 AlbanWende

Yes on android 4.1.2

trippo avatar Jan 26 '16 14:01 trippo

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.

floatinghotpot avatar Feb 23 '16 02:02 floatinghotpot

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.

prantikv avatar Feb 23 '16 13:02 prantikv

This still seems to be the case.

Brianchat avatar Aug 30 '16 14:08 Brianchat

For me it not working? any solution?

mbhd90 avatar Apr 27 '18 21:04 mbhd90