Android Question Firebase Notification and notification channel

voxel

Active Member
Licensed User
Hello,
I've implemented Firebase push notifications, but I don't have a notification channel (name: miscellaneous). I saw that there's also an NB6 library for implementing a notification channel. Should I use this library with Firebase notifications? If so, is there an example? Is there another solution?

Thank you for your help.
 

DonManfred

Expert
Licensed User
Longtime User
If so, is there an example?
Yes, SURE. Does the forumsearch did not work for you?

 
Upvote 0

voxel

Active Member
Licensed User
Hello,
When I use this code, I still get a notification category with the name "miscellaneous".

B4X:
Sub Process_Globals
    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 n As Notification
'    n.Initialize2(n.IMPORTANCE_DEFAULT)
'   
'    n.AutoCancel = True
'    n.Icon = "icon_notif"
'    n.SetInfo(Message.GetData.Get("title"), Message.GetData.Get("body"), Main)
'   
'    n.Notify(1)
    
    Private smiley As Bitmap
    smiley = LoadBitmapResize(File.DirAssets, "home.png", 24dip, 24dip, False)
    
    Dim n2 As NB6
    n2.Initialize("default", Application.LabelName, "DEFAULT").AutoCancel(True).SmallIcon(smiley)
    n2.Build(Message.GetData.Get("title"), Message.GetData.Get("body"), "tag1", Main).Notify(1) 'It will be Main (or any other activity) instead of Me if called from a service.
    
    

End Sub

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