Hello,
My code :
When a firebase message arrives I got to analyse it and make a notification with notification builder.
I have a strange problem: the customsound "pass.mp3" will not play, even when it should.
When I put a breakpoint and step into the code the sound plays ???
Somebody?
John
My code :
B4X:
Sub fm_MessageArrived (Message As RemoteMessage)
'Try
Log("Message arrived")
Log($"Message data: ${Message.GetData}"$)
Dim nb As NotificationBuilder
' Dim nbBigTextStyle As NotificationBigTextStyle
Dim title As String = Message.GetData.get("title")
'Log("title 2de karakter : " & title.SubString2(1,2))
Dim body As String = Message.GetData.Get("body")
Dim soort As Char = title.SubString2(0,1)
Dim severity As Int = title.SubString2(1,2)
Dim acttitle As String = title.SubString(2)
nb.Initialize
Select Case soort
Case "D"
nb.SmallIcon = "ic_home_variant_white_24dp"
Case "A"
nb.SmallIcon = "ic_bell_white_24dp"
Case "P"
nb.SmallIcon = "ic_gate_white_24dp"
Case "K"
nb.SmallIcon = "ic_panda_white_24dp"
Case Else
nb.SmallIcon = "icon"
End Select
nb.Ticker = "Robonotification"
nb.setActivity("modnotificatiesoort")
nb.ContentTitle = acttitle
nb.DefaultLight = True
nb.DefaultVibrate = False
nb.DefaultSound = False
Dim passSound As Boolean = False
Dim welk As Int
Select Case soort
Case "P"
welk = 0
Dim myfullname As String = Starter.pubuser.voornaam & " " & Starter.pubuser.naam
Dim searchbody As String = body.ToLowerCase
If searchbody.Contains(myfullname.ToLowerCase) = True Then
passSound = True
Log("pass")
nb.CustomSound = "file:///sdcard/Notifications/pass.mp3"
End If
Case "D"
welk = 1
Case "A"
welk = 2
Case "K"
welk = 3
End Select
Log(passSound)
If passSound = False Then
Select Case severity
Case 0
nb.CustomSound = ""
Case 1
nb.CustomSound = "file:///sdcard/Notifications/beep.mp3"
Case 2
nb.CustomSound = "file:///sdcard/Notifications/beep2.mp3"
Case 3
nb.CustomSound = "file:///sdcard/Notifications/beep3.mp3"
Case 4
nb.CustomSound = "file:///sdcard/Notifications/beep4.mp3"
Case 5
nb.CustomSound = "file:///sdcard/Notifications/beep5.mp3"
Case Else
nb.CustomSound = "file:///sdcard/Notifications/beep.mp3"
End Select
End If
Dim mynotification As notificationsoort
Dim n As Int
For Each mynotif As notificationsoort In Starter.lstNotifications
If mynotif.soort = soort Then
mynotification = mynotif
Exit
End If
Next
Dim returnvalue As Int = InsertNotification(acttitle,Message.GetData.Get("body"), soort,Message.GetData.Get("bodydetail") )
mynotification.nr = mynotification.nr + 1
nb.ContentText = Message.GetData.Get("body")
Log("Body detail : " & Message.GetData.Get("bodydetail") )
nb.Number = returnvalue 'mynotification.nr 'Starter.notificationNr
nb.Autocancel = True
nb.tag = soort
nb.Notify(welk) 'myid
'Catch
' Log(LastException)
'End Try
End Sub
When a firebase message arrives I got to analyse it and make a notification with notification builder.
I have a strange problem: the customsound "pass.mp3" will not play, even when it should.
When I put a breakpoint and step into the code the sound plays ???
Somebody?
John