Hide notifications to the user when app is in background


I need my application receives push notifications in order to update the information that is locally stored. These notifications has to be received when the app is in foreground and in background without user interaction. Actually i have got the app receive push notifications in foreground without this user interaction but when the app is in background the push notification is shown by the phone and it has to be opened by the user in order the app receives the event of “notification arrived”.

What i need is a way to receive notifications in background and these are not visible for the user and, at the same time, are received by the app.

Any idea?

Thanks in advance

I actually can’t think of a way where you would actually send a push notification, but don’t want the user to be able to see the notification? That fully beats the purpose of a push notification (which is a tell sign for the user there’s something there for them). Using them to trigger stuff in your app without the user knowing about it seems like a misusage of push notification to me.

What you’re actually looking for is a mechanism to trigger changes in your app without the user knowing. You could consider running the app in background mode, which you can give a notch and do your stuff. Or, just check every time the user opens up the app if there should be something done then.

According with Firebase documentation (https://firebase.google.com/docs/cloud-messaging/concept-options) there is a type of notifications (data messages) used in order to send info to the app but not to the user. Maybe i have not understand the behaviour but it seems that the app have to be able to receive notifications without user interaction.

Why you don’t just check on startup of your app if the data locally stored are up-to-date and if not, fetch them?

1 Like

Okay, didn’t know that! But what have you tried to set the key to data only (as per documentation)?

The API development is closed, so i cannot create a nwe services. I’m trying to use push because i have not other alternative at this moment. Thanks.

Yes, i have tried, but i’m not receiving push notifications when i set data key only.

1 Like

Well even if you will be able to push your notifications to your app without letting the user now (let’s say that possible) you would still have to trigger an action to fetch the data or even if you are able to send your data with the notification you still would need a way to get them and save them in the storage of your app…what I just want to display here is that in any case, you will need extra development…just a thought, take it or leave it of course :wink:

Good luck

Thanks. I have implemented the process of update but i need a way to receive the notification (is my original question)

1 Like

That’s a good solution. thank you.:sunglasses: