Bug? Typo in NB6 class causing erroneous channel name

Sandman

Expert
Licensed User
Longtime User
I think there's a typo in the NB6 class, found at https://www.b4x.com/android/forum/threads/nb6-notifications-builder-class-2018.91819/#content.

B4X:
Public Sub Initialize (ChannelId As String, ChannelName As Object, ImportanceLevel As String) As NB6
    ctxt.InitializeContext
    PendingIntentStatic.InitializeStatic("android.app.PendingIntent")
    NotificationStatic.InitializeStatic("android.app.Notification")
    common.InitializeStatic("anywheresoftware.b4a.keywords.Common")
    Dim jo As JavaObject
    SdkLevel = jo.InitializeStatic("android.os.Build$VERSION").GetField("SDK_INT")
    If SdkLevel < 23 Then
        SupportLevel = S_OLD
    Else if SdkLevel >= 26 Then
        SupportLevel = S_CHANNEL
    Else
        SupportLevel = S_BUILDER
    End If
    If IsOld Then
        OldNotification.Initialize
        OldNotification.Icon = "icon"
    Else if IsChannel Then
        ChannelId = ChannelId & "_" & ImportanceLevel
        NotificationBuilder.InitializeNewInstance("android.app.Notification$Builder", Array(ctxt, ChannelId))
        Dim im As Map = CreateMap("MIN": 1, "LOW": 2, "DEFAULT": 3, "HIGH": 4)
        Dim i As Int = im.Get(ImportanceLevel)
        Channel.InitializeNewInstance("android.app.NotificationChannel", Array(ChannelId, Application.LabelName, i))
    Else
        NotificationBuilder.InitializeNewInstance("android.app.Notification$Builder", Array(ctxt))
        Dim pm As Map = CreateMap("MIN": -2, "LOW": -1, "DEFAULT": 0, "HIGH": 1)
        Dim p As Int = pm.Get(ImportanceLevel)
        NotificationBuilder.RunMethod("setPriority", Array(p))
    End If
    If ImportanceLevel = "DEFAULT" Or ImportanceLevel = "HIGH" Then
        SetDefaults(True, True, True)
    Else
        SetDefaults(False, True, True)
    End If
    Return Me
End Sub

The ChannelName is never used. Instead Application.LabelName is used as name for the channel.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…