Android Question Firebase Notification receive case

taylorw

Active Member
Licensed User
Hi all, I usging Firebase for notification.

I have a problem with the notification, when user turn off they phone or no internet but after they connect to network or turn on they phone they no receive the notification.

Is any mistake for me?Please help for this.
 
This is my code.

Code:
Private Sub SendMessage(Topic As String, Title As String, Body As String)
    
    Dim Job As HttpJob
    Job.Initialize("fcm", Me)
    Dim m As Map = CreateMap("to": $"/topics/${Topic}"$)
    Dim data As Map = CreateMap("title": Title, "body": Body)
    
    m.Put("data", data)
    Dim jg As JSONGenerator
    jg.Initialize(m)
    Job.PostString("https://fcm.googleapis.com/fcm/send", jg.ToString)
    Job.GetRequest.SetContentType("application/json;charset=UTF-8")
    Job.GetRequest.SetHeader("Authorization", "key=" & Main.API_KEY)
    
End Sub

Code:
SendMessage(Notification_Topic, Notification_Title, Notification_Body)

Code:
Private fm As FirebaseMessaging

Sub Service_Create
    fm.Initialize("fm")
End Sub

Public Sub SubscribeToTopics
    
    fm.SubscribeToTopic(Notification_Topic)
    
End Sub

Sub Service_Start (StartingIntent As Intent)
    If StartingIntent.IsInitialized And fm.HandleIntent(StartingIntent) Then Return
    Notification_Topic.Initialize
    SFC.Initialize

End Sub

Sub fm_MessageArrived (Message As RemoteMessage)

    Dim n As Notification
    n.Initialize
    n.Icon = "icon"

            n.SetInfo2(Message.GetData.Get("title"), Message.GetData.Get("body"), Message.GetData.Get("StartDate"), frmLeave_List)
            
            n.AutoCancel = True
            n.Notify(Notification_Count)
            Notification_Count = Notification_Count +1
    
End Sub
 
Upvote 0
Upvote 0
Back
Top