Ulhas Rane
Member
Hi
I am using following event to received data from FCM receiver and build the notification with nb6 library, but i am not geting csbuilder formated text in notification body and title etc rather i am getting plain bare text in notification.
Thanks.
I am using following event to received data from FCM receiver and build the notification with nb6 library, but i am not geting csbuilder formated text in notification body and title etc rather i am getting plain bare text in notification.
Thanks.
Sub fm_MessageArrived (Message As RemoteMessage):
Sub fm_MessageArrived (Message As RemoteMessage)
'Log($"Message.GetData data: ${Message.GetData}"$)
'Message.GetData data: {Notchnlid=FCMCHidIMPAlert, Notchnlnm=FCMAlerting Messages, SubText=Device 3 : Started at 20:17:59, ID=23, Text=['Device 3 : Started at 19:49:30', 'Device 3 : Stopped at 19:50:02', 'Device 4 : Started at 19:50:10', 'Device 4 : Stopped at 19:50:18', 'Overhead Pump : Started at 20:02:22 > On Time 01:10:00', 'Overhead Pump : Stopped at 20:02:34 > On duration 00:00:12', 'Device 3 : Started at 20:14:56', 'Device 3 : Stopped at 20:15:15', 'Device 3 : Started at 20:17:59'], State=1, Title=Device 3, NoTFType=2, Device=3}
If B4XPages.IsInitialized And B4XPages.GetManager.IsForeground Then
Log("App is in the foreground. In iOS a notification will not appear while the app is in the foreground (unless UserNotificationCenter is used).")
End If
Dim FCMsmiley As Bitmap
Dim n As NB6
Dim cs As CSBuilder
FCMsmiley = LoadBitmapResize(File.DirAssets, "logo-02.png", 24dip, 24dip, False)
n.Initialize(Message.GetData.Get("Notchnlid"), Message.GetData.Get("Notchnlnm"), "DEFAULT").AutoCancel(True).SmallIcon(FCMsmiley)
n.AutoCancel(True) ' added latest
n.OnlyAlertOnce(True)
n.SubText(cs.Initialize.BackgroundColor(Colors.Yellow).Append("Sub text").PopAll)
Dim title As Object = cs.Initialize.Color(Colors.Green).Append(Message.GetData.Get("title").As(String)).PopAll
Dim Content As Object = cs.Initialize.Underline.Bold.Color(Colors.Magenta).Append(Message.GetData.Get("body").As(String)).PopAll
'Dim largeIcon As Bitmap = LoadBitmapResize(File.DirAssets, "logo-02.png", 256dip, 256dip, True)
'n.LargeIcon(largeIcon)
n.Color(Colors.Blue)
n.BadgeIconType("SMALL").Number(Message.GetData.Get("ID").As(Int))
n.ShowWhen(DateTime.Now)
'n.Build(title, Content, "tag2", Main).Notify(Message.GetData.Get("ID").As(Int))
Dim FCMNBB As Notification
FCMNBB = n.Build(title, Content, "tag2", Main)
FCMNBB.Notify(Message.GetData.Get("ID").As(Int))
End Sub
Last edited: