This is a mistake. Watch the video tutorial.
I watched. But nothing changed.
I agree that StartAtBoot has no effect.
I tried a lot of combinations. For example,
Sub firebasemessagingInstance_MessageArrived (Message As RemoteMessage)
Dim notificationbuilderInstance As NotificationBuilder
If Common.bytePhoneSdkVersion >= 26 Then
firebasemessagingInstance_MessageArrived_API26 (Message)
Else
notificationbuilderInstance.Initialize
notificationbuilderInstance.ContentTitle = Message.GetData.Get ("title")
notificationbuilderInstance.ContentText = Message.GetData.Get ("body")
notificationbuilderInstance.SmallIcon = "icon"
notificationbuilderInstance.Priority = 2
notificationbuilderInstance.AutoCancel = True
notificationbuilderInstance.DefaultSound = True
notificationbuilderInstance.OnGoingEvent = True
notificationbuilderInstance.setActivity (Main)
notificationbuilderInstance.Notify (1)
End If
End Sub
Sub firebasemessagingInstance_MessageArrived_API26 (Message As RemoteMessage)
Dim notificationInstance As Notification
notificationInstance.Initialize2 (notificationInstance.IMPORTANCE_HIGH)
notificationInstance.AutoCancel = True
notificationInstance.Icon = "icon"
notificationInstance.Sound = True
notificationInstance.OnGoingEvent = True
notificationInstance.SetInfo (Message.GetData.Get ("title"), Message.GetData.Get ("body"), Main)
notificationInstance.Notify (1)
End Sub
Results are the same. When an app is opened, the notification appears like expected (popup and sound). But when the app is closed, no sound and doesn't popup. Unlike new notification appears in tray.
It looks that code as it is correct. Probably, the reason in permissions. My son uses Xiaomi redmi 4x for tests. He read an article
https://www.androidcentral.com/how-fix-push-notifications-miui-8 and changed some flags, using GMail as layout. After this the phone began to show notifications correctly (even if my app is not started, there is a sound, and message popups). Unf., my son is not Android developer and can't explain details.