Hi, I have an app that sends SMS and I want to start monitoring the delivery reports to be sure that the messages were in fact delivered to the other side.
This is the part of the code that matters:
And this works. I get the delivery report. But when the destination phone is Airplane mode (no network) and the SMS is kept in the Service Center I receive one delivery report, and when I turn the destination phone back ON I get another delivery report with different PDU content.
This is my log when I send the SMS to a mobile phone that is in Airplane mode:
> Sending SMS to xxxxxxxxxxxx
> SMSSentStatus:true:OK:+xxxxxxxxxxxx
I receive this a few seconds after the SMS has been sent:
> Receipt from: +xxxxxxxxxxxx
> Receipt Intent: (Intent) Intent { act=b4a.smsdelivered flg=0x10 (has extras) }
> Receipt GetData: null
> Receipt Action: b4a.smsdelivered
> Receipt Flags: 16
> Receipt ExtrasToString: Bundle[{format=3gpp, pdu=[B@9015592, phone=+xxxxxxxxxxxx}]
Then I take the destination phone from Airplane mode so it receives the SMS and I get this:
> Receipt from: +xxxxxxxxxxxx
> Receipt Intent: (Intent) Intent { act=b4a.smsdelivered flg=0x10 (has extras) }
> Receipt GetData: null
> Receipt Action: b4a.smsdelivered
> Receipt Flags: 16
> Receipt ExtrasToString: Bundle[{format=3gpp, pdu=[B@e901b63, phone=+xxxxxxxxxxxx}]
So the first delivery report should tell me that the SMS was sent but not delivered to the destination (pending in the Service Center).. and the second delivery report should tell me that the SMS was actually delivered to the destination.
My question is how to know the diference between "sent/pending" and "delivered" based on the PDU code received? Because I cannot be sure that the PDU will be the same on all phones/networks.
Thanks in advance!
This is the part of the code that matters:
B4X:
Dim ThisPhoneSms As PhoneSms
Dim PhoneId As PhoneId
Dim PE As PhoneEvents
(...)
PE.InitializeWithPhoneState("PE", PhoneId)
(...)
ThisPhoneSms.Send("+" & SMSDestination, SMSMessage)
(...)
Sub PE_SmsDelivered (PhoneNumber As String, Intent As Intent)
Log ("Receipt from: " & PhoneNumber)
Log ("Receipt Intent: " & Intent)
Log ("Receipt GetData: " & Intent.GetData)
Log ("Receipt Action: " & Intent.Action)
Log ("Receipt Flags: " & Intent.Flags)
Log ("Receipt ExtrasToString: " & Intent.ExtrasToString)
End Sub
And this works. I get the delivery report. But when the destination phone is Airplane mode (no network) and the SMS is kept in the Service Center I receive one delivery report, and when I turn the destination phone back ON I get another delivery report with different PDU content.
This is my log when I send the SMS to a mobile phone that is in Airplane mode:
> Sending SMS to xxxxxxxxxxxx
> SMSSentStatus:true:OK:+xxxxxxxxxxxx
I receive this a few seconds after the SMS has been sent:
> Receipt from: +xxxxxxxxxxxx
> Receipt Intent: (Intent) Intent { act=b4a.smsdelivered flg=0x10 (has extras) }
> Receipt GetData: null
> Receipt Action: b4a.smsdelivered
> Receipt Flags: 16
> Receipt ExtrasToString: Bundle[{format=3gpp, pdu=[B@9015592, phone=+xxxxxxxxxxxx}]
Then I take the destination phone from Airplane mode so it receives the SMS and I get this:
> Receipt from: +xxxxxxxxxxxx
> Receipt Intent: (Intent) Intent { act=b4a.smsdelivered flg=0x10 (has extras) }
> Receipt GetData: null
> Receipt Action: b4a.smsdelivered
> Receipt Flags: 16
> Receipt ExtrasToString: Bundle[{format=3gpp, pdu=[B@e901b63, phone=+xxxxxxxxxxxx}]
So the first delivery report should tell me that the SMS was sent but not delivered to the destination (pending in the Service Center).. and the second delivery report should tell me that the SMS was actually delivered to the destination.
My question is how to know the diference between "sent/pending" and "delivered" based on the PDU code received? Because I cannot be sure that the PDU will be the same on all phones/networks.
Thanks in advance!