Android Question Clicking the notification only opens the app when the app has been manually opened at least once.

Alankoba

Member
Licensed User
Longtime User
Firebase Push messages


B4X:
Sub Service_Start (StartingIntent As Intent)
    If StartingIntent.IsInitialized Then fm.HandleIntent(StartingIntent)
    Sleep(0) ' i Testet whitout this line
    Service.StopAutomaticForeground 'remove if not using B4A v8+.
End Sub



Lib FireBaseNotifications: 1.21
B4A Versions: 9.50 BETA 1, 9.30 Stable
 

Alankoba

Member
Licensed User
Longtime User
Firebase creates a notification automatically, even without any code in fm_MessageArrived. When the app is open (showing on screen) then the fm_MessageArrived event is fired, and a msgBox is displayed.

B4X:
Sub fm_MessageArrived (Message As RemoteMessage)
    Log("Message arrived")
    Log($"Message data: ${Message.GetData}"$)
    CallSub3(Main, "msgPush", Message.GetData.Get("title"), Message.GetData.Get("body"))
End Sub
 
Upvote 0

Alankoba

Member
Licensed User
Longtime User
After 45 seconds of clicking (approximate time) the app opens correctly. Can this be something with the foreground?
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Firebase creates a notification automatically, even without any code in fm_MessageArrived.
No it doesn't. You are probably seeing the automatic foreground notification.

The only way to start an activity from a service, while the app is in the background, is by calling StartActivity.
 
Upvote 0
Top