Hi everyone,
I've been using Firebase push notifications in my B4i app for many years. Overall, it has worked well, but I often receive reports from users saying that sometimes notifications stop arriving when the app is in the background or closed, even if it had just received some shortly before.
I followed the official tutorial which includes the following code:
However, I suspect that calling fm.FCMDisconnect may actually prevent the app from receiving push notifications while it's in the background, or at least cause them to stop after a short time.
I ran tests using the official B4J sending tool: when the app goes to the background, it initially receives notifications, but after sometime, lets's say tenth of minutes, they completely stop arriving. This behavior matches what other users have reported searching in the forum.
At the moment, I'm trying to remove fm.FCMDisconnect and keep the connection always active to see if it improves reliability when the app is in the background.
My questions are:
Thanks to anyone willing to share their experience!
edit:
I'm noticing something interesting:
Application_Background is not called if the user explicitly closes the app (by swiping it away, for example), instead of just moving it to the background. So fm.FCMDisconnect is only called when the app is moved to the background — and in this case, notifications stop arriving shortly after.
On the other hand, if the user closes the app, fm.FCMDisconnect is not called, and notifications continue to arrive even after an hour.
This might explain why some users report that notifications sometimes stop arriving — they may not realize that it depends on how they “closed” the app.
So my question remains:
Why does the tutorial recommend calling fm.FCMDisconnect if this seems to actually prevent receiving notifications — especially considering that push notifications are most useful when the app is closed or inactive?
I've been using Firebase push notifications in my B4i app for many years. Overall, it has worked well, but I often receive reports from users saying that sometimes notifications stop arriving when the app is in the background or closed, even if it had just received some shortly before.
I followed the official tutorial which includes the following code:
B4X:
App.RegisterUserNotifications(True, True, True) 'allow badge, sound and alert
App.RegisterForRemoteNotifications ' chiama Sub Application_PushToken
fm.Initialize("fm")
Sub Application_Background
fm.FCMDisconnect
End Sub
Sub Application_Active
fm.FCMConnect
End Sub
However, I suspect that calling fm.FCMDisconnect may actually prevent the app from receiving push notifications while it's in the background, or at least cause them to stop after a short time.
I ran tests using the official B4J sending tool: when the app goes to the background, it initially receives notifications, but after sometime, lets's say tenth of minutes, they completely stop arriving. This behavior matches what other users have reported searching in the forum.
At the moment, I'm trying to remove fm.FCMDisconnect and keep the connection always active to see if it improves reliability when the app is in the background.
My questions are:
- Is it possible that fm.FCMDisconnect breaks the connection to Firebase/APNs and stops notifications from being delivered while the app is not active?
- Why is this call still recommended in the tutorial? Is this approach still valid today?
- Has anyone solved similar issues by removing fm.FCMDisconnect?
Thanks to anyone willing to share their experience!
edit:
I'm noticing something interesting:
Application_Background is not called if the user explicitly closes the app (by swiping it away, for example), instead of just moving it to the background. So fm.FCMDisconnect is only called when the app is moved to the background — and in this case, notifications stop arriving shortly after.
On the other hand, if the user closes the app, fm.FCMDisconnect is not called, and notifications continue to arrive even after an hour.
This might explain why some users report that notifications sometimes stop arriving — they may not realize that it depends on how they “closed” the app.
So my question remains:
Why does the tutorial recommend calling fm.FCMDisconnect if this seems to actually prevent receiving notifications — especially considering that push notifications are most useful when the app is closed or inactive?
Last edited: