Android Question New Firebase Integration

svitol

Member
Hi, i want to integrate Firebase Messaging into my app..
I follow this tutorial
But when app start i receive this message:
B4X:
java.lang.RuntimeException: Object should first be initialized (FirebaseMessaging).

becouse "Receiver_Receive" not calling
B4X:
Private Sub Receiver_Receive (FirstTime As Boolean, StartingIntent As Intent)
    If FirstTime Then
        fm.Initialize("fm")
    End If
    fm.HandleIntent(StartingIntent)
End Sub

Where is the problem?
Thank you
 

svitol

Member
My service
B4X:
#Region  Service Attributes
    #StartAtBoot: False
    
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Private fm As FirebaseMessaging
End Sub


Private Sub Receiver_Receive (FirstTime As Boolean, StartingIntent As Intent)
    If FirstTime Then
        fm.Initialize("fm")
    End If
    fm.HandleIntent(StartingIntent)
End Sub

Public Sub SubscribeToTopics
    fm.SubscribeToTopic("general")
End Sub

Sub fm_MessageArrived (Message As RemoteMessage)
    Log("Message arrived")
    Log($"Message data: ${Message.GetData}"$)
    Dim n2 As Notification
    n2.Initialize2(n2.IMPORTANCE_DEFAULT)
    n2.Icon = "icon"
    n2.SetInfo(Message.GetData.Get("title"), Message.GetData.Get("body"), Main)
    n2.Notify(1)
End Sub

Sub fm_TokenRefresh (Token As String)
    Log("TokenRefresh: " & Token)
End Sub
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
My service
is OUTDATED... Check the Firebasemessaging tutorial.

There is no single Service involved in Firebasemessagin in 2023.

 
Upvote 1

svitol

Member
I followed this tutorials
and i send regular notification with b4j app test but not shows in my b4a application
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
and i send regular notification with b4j app test but not shows in my b4a application
- You should start a new thread for a new question
- We can not help you if you HIDE 100% of the details. No code, no manifest, no example project, no info on how you send the Notification. All this has changed and you need to adapt to the new Tutorial...
 
Upvote 0
Top