I try to get the content of a sms from an intent but so far without any success. I can see the messege bundel, and the pdus but i can't understant how to extract the content in some human readble format.
Here is my code:
Application.android.registerBroadcastReceiver(
'android.provider.Telephony.SMS_RECEIVED',
(context, intent: android.content.Intent) => {
console.log("SMS Recived");
const pdus = intent.getExtras().get("pdus");
//HOW TO EXTRACT THE MESSAGE HERE?
}
When i tried to do it like in android i am getting an error
const pdus = intent.getExtras().get("pdus");
android.telephony.SmsMessage.createFromPdu(pdus);
Thanks for your help
So at the end i solve the problem by bumping up the sdk from 17 to a version that telephony.sms exists and used another function to get the intent data.
(context, intent: android.content.Intent) => {
const msgs = android.provider.Telephony.Sms.Intents.getMessagesFromIntent(intent);
const msg = msgs[0];
const sender = msg.getDisplayOriginatingAddress();
const content = msg.getDisplayMessageBody();
}
if someone has another slution without bumping the sdk version i would be happy to see