Hi,
I 'm working on an app that sends SMS and receives the delivery reports. My problem is that I need to match the delivery report with the sent SMS. Matching the Sent/Report by phone number is not an option because I can send several SMS to the same number.
This is my test code:
The log I get:
I've hidden the destination number for privacy issues.
So, I see in the log that the SMS was sent and delivered.
When the SMS is delivered, I can see its PDU. Using this website to decode it, I can see that there is a value called "Reference" (Value "137") that is incremented automatically on each SMS I send.
(great article on how to decude PDU messages here)
According to the GSM specification, this "Reference" value in the delivery report is called TP-MR. It is the same as the TP-MR of the sent SMS for which the delivery report has been received.
This is exactly what I need: I need to know the reference number (TP-MR) of the sent SMS so that when I receive the delivery report I can match it with its reference number (TP-MR).
Does anyone know how to do this?
Regards,
Jorge
I 'm working on an app that sends SMS and receives the delivery reports. My problem is that I need to match the delivery report with the sent SMS. Matching the Sent/Report by phone number is not an option because I can send several SMS to the same number.
This is my test code:
B4X:
Sub Globals
Dim ThisPhoneSms As PhoneSms
Dim PhoneId As PhoneId
Dim PE As PhoneEvents
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("deliveryreporttest.bal")
PE.InitializeWithPhoneState("PE", PhoneId)
ThisPhoneSms.Send2("+xxxxxxxxxxxx", "Test", True, True)
End Sub
Sub PE_SmsSentStatus (Success As Boolean, ErrorMessage As String, PhoneNumber As String, Intent As Intent)
Log("--- PE_SmsSentStatus ---")
Log("Success:" & Success)
Log("ErrorMessage:" & ErrorMessage)
Log("PhoneNumber:" & PhoneNumber)
Log("Sent Intent: " & Intent)
Log("Sent Intent GetData: " & Intent.GetData)
Log("Sent Intent Action: " & Intent.Action)
Log("Sent Intent Flags: " & Intent.Flags)
Log("Sent Intent ExtrasToString: " & Intent.ExtrasToString)
End Sub
Sub PE_SmsDelivered (PhoneNumber As String, Intent As Intent)
Log("--- PE_SmsDelivered ---")
Log("PhoneNumber:" & PhoneNumber)
Log("Delivered Intent: " & Intent)
Log("Delivered Intent GetData: " & Intent.GetData)
Log("Delivered Intent Action: " & Intent.Action)
Log("Delivered Intent Flags: " & Intent.Flags)
Log("Delivered Intent ExtrasToString: " & Intent.ExtrasToString)
Log("Delivered Intent GetExtra(PDU): " & Intent.GetExtra("pdu"))
Dim bc As ByteConverter
Log("Decoded PDU: " & bc.HexFromBytes(Intent.GetExtra("pdu")))
End Sub
The log I get:
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
--- PE_SmsSentStatus ---
Success:true
ErrorMessage:OK
PhoneNumber:+xxxxxxxxxxxx
Sent Intent: (Intent) Intent { act=b4a.smssent flg=0x10 (has extras) }
Sent Intent GetData: null
Sent Intent Action: b4a.smssent
Sent Intent Flags: 16
Sent Intent ExtrasToString: Bundle[{pdu_size=18, phone=+xxxxxxxxxxxx}]
--- PE_SmsDelivered ---
PhoneNumber:+xxxxxxxxxxxx
Delivered Intent: (Intent) Intent { act=b4a.smsdelivered flg=0x10 (has extras) }
Delivered Intent GetData: null
Delivered Intent Action: b4a.smsdelivered
Delivered Intent Flags: 16
Delivered Intent ExtrasToString: Bundle[{pdu=[B@41684508, phone=+xxxxxxxxxxxx, format=3gpp}]
Delivered Intent GetExtra(PDU): [B@41684508
Decoded PDU: 07910000000000F406880C91000000000006610131213075406101312130954000
I've hidden the destination number for privacy issues.
So, I see in the log that the SMS was sent and delivered.
When the SMS is delivered, I can see its PDU. Using this website to decode it, I can see that there is a value called "Reference" (Value "137") that is incremented automatically on each SMS I send.
(great article on how to decude PDU messages here)
According to the GSM specification, this "Reference" value in the delivery report is called TP-MR. It is the same as the TP-MR of the sent SMS for which the delivery report has been received.
This is exactly what I need: I need to know the reference number (TP-MR) of the sent SMS so that when I receive the delivery report I can match it with its reference number (TP-MR).
Does anyone know how to do this?
Regards,
Jorge