PC SOFT

PROFESSIONAL NEWSGROUPS
WINDEVWEBDEV and WINDEV Mobile

Home → WINDEV Mobile 2024 → New SMS received
New SMS received
Started by Gautam, Jun., 01 2017 8:41 AM - 2 replies
Registered member
67 messages
Posted on June, 01 2017 - 8:41 AM
Hi All

I am developing an app that needs to read incoming SMS messages (Android 6.01).

How do we retrieve a list of only the NEW SMS received since the last read?

My code is something like this:

ResRead is boolean = SMSFirst(smsSIM)

WHILE ResRead = True
TableAddLine(TABLE_SMSTable, SMS.Subscript, SMS.Message, SMS.Number, SMS.ReceiveDate)
// Read the other SMSs
ResRead = SMSNext(smsSIM)
END

However, using the above code SMSFirst always seems to retrieve the very first sms that has been previously read. I would like to only retrieve SMS that are NEW and have not been retrieved in the past.

Is there a way to mark an SMS as Read so that SMSFirst does not retrieve this anymore?

I could delete the SMS after reading and retrieving the content (SMSDelete) however this only seems to work for Android KitKat and earlier.

How have you done it?

Thanks and regards

Gautam
Registered member
637 messages
Popularité : +36 (36 votes)
Posted on June, 01 2017 - 11:06 AM
Hi,

After reading all SMS you can memorize le last indice (SMS.indice) read in a parameters file for instance.
SMS.indice is a unique number. Even if you delete all SMS from the mobile, the next new received SMS will have indice+1

Next time you read received SMS, you should always read all SMS but you can manage from the last indice you have memorized.


Unfortunately, it is not possible anymore to delete any SMS since recent android version.

Regards,
Eric.

--
Eric DELATTRE
http://www.yoosite.fr
Registered member
67 messages
Posted on June, 01 2017 - 12:10 PM
Wonderful! Thank you Eric for that suggestion. The help on SMS Structure (in English Version) has it as "Subscript - Integer corresponding to the subscript of the incoming SMS." I thought this was to identify a multi-part SMS where a long message is split into several parts and not a unique identifying value. If the subscript (indice) is a unique value then this will definitely work for me. I will try it out immediately.

Thanks once again! Much appreciated.

Gautam