Hi,
I am sending 80 tokens and one is broken (I manipulated one , or its from the develope testing)
than all 80 tokens are not accepted (not sending notifications)
I get back status = 8 in sub astream_NewData
What I need is a response after each token I send. Like a flush --> astream_NewData)
IOSFeedBack is delivering nothing.
I am sending 80 tokens and one is broken (I manipulated one , or its from the develope testing)
than all 80 tokens are not accepted (not sending notifications)
I get back status = 8 in sub astream_NewData
What I need is a response after each token I send. Like a flush --> astream_NewData)
IOSFeedBack is delivering nothing.
B4X:
Private Sub astream_NewData (Buffer() As Byte)
If Buffer.Length >=6 Then
Log("status=" & Buffer(1))
Else
Log("Invalid response")
End If
End Sub
B4X:
Public Sub SendMessageTo(Devices As List, msg As Message)
Log("send message to")
Dim out As OutputStream
out.InitializeToBytesArray(0)
For Each device As String In Devices
Dim FrameData As OutputStream
FrameData.InitializeToBytesArray(0)
WriteItem(FrameData, 1, bc.HexToBytes(device))
Dim jg As JSONGenerator
Dim m As Map = CreateMap("alert": CreateMap("title": "my title", "body": msg.Text), "badge": msg.Badge)
If msg.Sound Then m.Put("sound", "default")
jg.Initialize(CreateMap("aps":m))
'jg.Initialize(CreateMap("aps":CreateMap("content-available": 1)))
WriteItem(FrameData,2, jg.ToString.GetBytes("UTF8"))
WriteItem(FrameData,3, bc.IntsToBytes(Array As Int(Rnd(0, 9999999))))
WriteItem(FrameData,4, bc.IntsToBytes(Array As Int(msg.ExpirationDate / 1000)))
Dim p As Byte
If msg.HighPriority Then p = 10 Else p = 5
WriteItem(FrameData,5, Array As Byte(p))
Dim payload() As Byte = FrameData.ToBytesArray
out.WriteBytes(Array As Byte(2), 0, 1)
out.WriteBytes(bc.IntsToBytes(Array As Int(payload.Length)), 0, 4)
out.WriteBytes(payload, 0, payload.Length)
Next
astream.Write(out.ToBytesArray)
End Sub