I'm trying to create a widget app with a firebase push notification. My problem is it successfully subscribe to a topic but when message arrived it cannot capture it. Phone is just showing a notification that firebase message arrive but it is not part of my application.
Then i tried to create an app which is not a widget app. In this app firebase successfully captured by my application.
Here how i made my app.
As Erel sample on creating a widget. I create a service named Widget Service
Then i create a seperate service for Firebase
For this code i just do a logs and no notification but my phones displays a notification
Firebase setup works fine without any error on compiling and running. It just cannot capture the firebase message.
Then i tried to create an app which is not a widget app. In this app firebase successfully captured by my application.
Here how i made my app.
As Erel sample on creating a widget. I create a service named Widget Service
B4X:
Sub Process_Globals
Dim rv As RemoteViews
Dim count As Int = 0
End Sub
Sub Service_Create
rv = ConfigureHomeWidget("1", "rv", 0, "SFA Widget")
CallSubDelayed(FirebaseMessaging, "SubscribeToTopics")
End Sub
Sub Service_Start (StartingIntent As Intent)
If rv.HandleWidgetEvents(StartingIntent) Then Return
End Sub
Sub Service_TaskRemoved
End Sub
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub
Sub Service_Destroy
End Sub
Sub rv_RequestUpdate
rv.UpdateWidget
End Sub
Sub rv_Disabled
StopService("")
End Sub
Then i create a seperate service for Firebase
B4X:
Sub Process_Globals
Dim fm As FirebaseMessaging
End Sub
Sub Service_Create
fm.Initialize("fm")
End Sub
Sub Service_Start (StartingIntent As Intent)
If StartingIntent.IsInitialized Then fm.HandleIntent(StartingIntent)
Sleep(0)
Service.StopAutomaticForeground
End Sub
Sub Service_Destroy
End Sub
Public Sub SubscribeToTopics
Log("SubscribeToTopics")
fm.SubscribeToTopic("sfa")
End Sub
Sub fm_MessageArrived (Message As RemoteMessage)
Log("Message arrived")
End Sub
For this code i just do a logs and no notification but my phones displays a notification
Firebase setup works fine without any error on compiling and running. It just cannot capture the firebase message.