Iam currently using firebase to send notification to all users . but sometimes you find that some users phone may either be off or due to internet challenges my not receive notification at that time . When i send notification i save a copy into my database .so is their a way of automatically bring back the sent messages immediately when ever there is internet connectivity even when the user has not opened the app. as it is with Whatsapp. because as soon as you connect the internet the messages automatically comes thanks in advance.
The code i have here returns the messages only when some has opened the app . But i wanted these messages to automatically come as soon as there is internet connectivity. because what happens with firebase notification they only come when the phone is currently on at that time . if the phone is switch on the second day they don't come . So i wanted as soon as internet is detected then the person who didnt get a message can automatically be notified when he has not opened the app
The code i have here returns the messages only when some has opened the app . But i wanted these messages to automatically come as soon as there is internet connectivity. because what happens with firebase notification they only come when the phone is currently on at that time . if the phone is switch on the second day they don't come . So i wanted as soon as internet is detected then the person who didnt get a message can automatically be notified when he has not opened the app
B4X:
Sub Service_Start (StartingIntent As Intent)
cursor = SQL1.ExecQuery("SELECT phone AS Phone,Sex FROM Register")
If cursor.RowCount > 0 Then
cursor.Position =0
Dim Phonet As String
Phonet = cursor.Getstring("Phone")
Dim sx As String
sx = cursor.Getstring("Sex")
' sx = "Father"
End If
Dim CustID As String = Phonet' Customer ID
Dim jtk As HttpJob
jtk.Initialize("", Me)
'j.Download("http://192.168.1.239/Generic_Handler_JSON/HandlerVB.ashx?customerid=" & CustID)
jtk.Download("http://kccug.com/Generic_Handler_JSON/HandlerVBGetreply.ashx?customerid=" & CustID & "&bcode=" & sx)
'jtk.Download("http://192.168.1.239/Generic_Handler_JSON/HandlerVBGetreply.ashx?customerid=" & CustID & "&bcode=" & sx)
'jtk.GetRequest.Timeout = 10000 ' 10 seconds
Wait For (jtk) JobDone(jtk As HttpJob)
If jtk.Success Then ' if job is success (http status code 200)
Dim RetVal As String
Log(RetVal)
RetVal = jtk.GetString
If jtk.GetString = "[]" Then
'Msgbox("Please try Again ","SMIS")
'Return
Else
Dim jpt As JSONParser
jpt.Initialize(jtk.GetString)
'Log(jpt) ' will pr
Log($"Token(${jpt})"$)
Dim quotes As List = jpt.NextArray
For Each quot As Map In quotes
Log("Account: " & quot.Get("Account"))
Log("sms: " & quot.Get("sms"))
Log("Datesent: " & quot.Get("Datesent"))
Service.StartForeground(nid, CreateNotification(quot.Get("sms")))
StartServiceAt(Me, DateTime.Now + 60 * DateTime.TicksPerMinute, True)
Next
End If
End If
End Sub
Last edited: