I sent a notification from the firebase console if the application is closed there is no error but when the application is open I have the following error .
what should I do?
this is the code, guided in this tutorial -> https://www.b4x.com/android/forum/t...-messages-firebase-cloud-messaging-fcm.67716/
what should I do?
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
POL : 1
*** Service (firebasemessaging) Create ***
** Service (firebasemessaging) Start **
** Activity (main) Pause, UserClosed = true **
** Activity (menu) Create, isFirst = true **
** Activity (menu) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
** Service (httputils2service) Start **
** Receiver (firebasemessaging) OnReceive **
** Service (firebasemessaging) Start **
Message arrived
Message data: {}
firebasemessaging_fm_messagearrived (java line: 155)
java.lang.RuntimeException: Cannot change properties after call to SetInfo. Initialize the notification again.
at anywheresoftware.b4a.objects.NotificationWrapper.getND(NotificationWrapper.java:92)
at anywheresoftware.b4a.objects.NotificationWrapper.setFlag(NotificationWrapper.java:156)
at anywheresoftware.b4a.objects.NotificationWrapper.setAutoCancel(NotificationWrapper.java:130)
at netlabel.bancodepreguntasantpremium.firebasemessaging._fm_messagearrived(firebasemessaging.java:155)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.BA$1.run(BA.java:335)
at android.os.Handler.handleCallback(Handler.java:761)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6523)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:941)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:831)
this is the code, guided in this tutorial -> https://www.b4x.com/android/forum/t...-messages-firebase-cloud-messaging-fcm.67716/
B4X:
#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("Message arrived")
Log($"Message data: ${Message.GetData}"$)
Dim n As Notification
n.Initialize
n.Icon = "icon"
n.SetInfo(Message.GetData.Get("title"), Message.GetData.Get("body"), Menu)
n.AutoCancel=True
n.Notify(1)
End Sub
Sub Service_Destroy
End Sub