iOS Question Intercept Firebase Messages (iosalert) while in background to store a state

Mike1970

Well-Known Member
Licensed User
Longtime User
Hi everyone, i'm struggling finding the best solution to implement the notifications in my iOS app.

I have two FB topics, one for syncing informations between the app and my server. (this should be silent push notification, and happends only in foreground)
the second FB topic, instead, is for actual notifications that i want to display, BUT i want also to save some data in the phone.

Example:
I want to notify my users when an update of the app is available sending a notification (with iosalert, so it displays automatically).
When the phone receive the message i want to update an existing map file, so, when the users will open the app the next time, in the file that was updated before, there is a sort of "flag", so i can show a dialog.


It's possibile to do something like that in iOS?

I also whant to display the badgenumber on the app icon, because it isn't automatic i was trying with:
B4X:
Private Sub Application_RemoteNotification (Message As Map, CompletionHandler As CompletionHandler)
    Log($"Message arrived: ${Message}"$)
    
    App.ApplicationIconBadgeNumber = App.ApplicationIconBadgeNumber + 1

    CompletionHandler.Complete
End Sub
Before realize that in background this sub is not called 😕

I found out that silent notifications are not delivered when the user close the app, the "RemoteMessage" sub fires only when i click on the notification or the app is already in foreground.

There is a way to do what i need? it seems so painful 😅 😂

Thanks!!
 

Mike1970

Well-Known Member
Licensed User
Longtime User
Don't use push notifications to synchronize anything. When the app starts it should send a request to your server and be updated with any information it needs.

Yes I know, I use them to sync the app while is foreground, to update the content in live, if necessary.

The main problem is to put a flag in the phone when (for example) an update is available, so when the user will the open the app will see a dialog, and then the flag is removed, so the next time the dialog doesn't appear again.
 
Upvote 0
Top