Hi i trying to receive messages and always get the messages sent ok but sometimes the app receives and sometimes not.
This is the same implemented on python (my app backend is on python, i tried with the python firebase-admin package and said sucess but nothing happen.
When i use firebase-admin its even odd as when the app is not running i receive the messages with an ugly icon but when the app is running i receive an empty message:
When i use the code above its works sometimes, and sometimes not but always with a nice icon.
The service used to catch the message is:
And the starter code is this
may i using something wrong
This is the same implemented on python (my app backend is on python, i tried with the python firebase-admin package and said sucess but nothing happen.
When i use firebase-admin its even odd as when the app is not running i receive the messages with an ugly icon but when the app is running i receive an empty message:
When i use the code above its works sometimes, and sometimes not but always with a nice icon.
The service used to catch the message is:
B4X:
'THe service call "FirebaseMessaging"
#Region Service Attributes
#StartAtBoot: False
#End Region
Sub Process_Globals
Private fm As FirebaseMessaging
End Sub
Sub Service_Create
fm.Initialize("fm")
End Sub
Public Sub SubscribeToTopics
fm.SubscribeToTopic("general") 'you can subscribe to more topics
End Sub
Sub Service_Start (StartingIntent As Intent)
If StartingIntent.IsInitialized Then fm.HandleIntent(StartingIntent)
Sleep(0)
Service.StopAutomaticForeground 'remove if not using B4A v8+.
End Sub
Sub fm_MessageArrived (Message As RemoteMessage)
Log("Mensage recibido")
Log($"Datos del mensaje: ${Message.GetData}"$)
Dim n26 As NB6
Dim b As Bitmap
b.Initialize(File.DirAssets,"icono64x64.png")
n26.Initialize("default", Application.LabelName, "DEFAULT").AutoCancel(True).SmallIcon(b)
n26.Build(Message.GetData.Get("title"), Message.GetData.Get("body"), "tag1", Main).Notify(4) 'It will be Main (or any other activity) instead of Me if called from a service.
End Sub
Public Sub SetApiRestToken
REST.API.FirebaseCloudMessagingToken = fm.Token
Log(fm.Token)
End Sub
Sub Service_Destroy
End Sub
And the starter code is this
B4X:
#Region Service Attributes
#StartAtBoot: False
#ExcludeFromLibrary: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Service_Create
'This is the program entry point.
'This is a good place to load resources that are not specific to a single activity.
REST.Start()
CallSubDelayed(FirebaseMessaging, "SubscribeToTopics")
CallSubDelayed(FirebaseMessaging, "SetApiRestToken")
End Sub
Sub Service_Start (StartingIntent As Intent)
Service.StopAutomaticForeground 'Starter service can start in the foreground state in some edge cases.
End Sub
Sub Service_TaskRemoved
'This event will be raised when the user removes the app from the recent apps list.
End Sub
'Return true to allow the OS default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub
Sub Service_Destroy
may i using something wrong