Search code examples
iphoneobjective-cjailbreak

Is there a way to programmatically delete an sms from iPhone inbox?


My iPhone is jailbroken and I don't have to submit the app to the App store. So any solution is ok. I just want to know if there was a way to programmatically delete an sms containing a particular string from iPhone inbox?

setuid(0);

sqlite3 *database;

NSString *path = @"/var/mobile/Library/SMS/sms.db";

sqlite3_open([path UTF8String], &database);

NSString *deleteStatement = @"delete from message";

char *error;
sqlite3_exec(database, [deleteStatement UTF8String], NULL, NULL, &error) ;

sqlite3_close(database);

This is my code. It's written in the main method. There is nothing else in my code.


Solution

  • You have to take care of the triggers also.

    You can drop it using something like:

    drop trigger if exists delete_message;
    

    and then you can proceed eliminating the messages. After that, you should recreate the trigger:

    CREATE TRIGGER if not exists delete_message AFTER DELETE ON message WHEN NOT read(old.flags)
    

    Anyway, in general, you can take a look at this other question very similar to yours: delete message on sqlite. jailbreak iphone