OneSignal/OneSignal-Android-SDK

[question]: I close the app and open it again and push notifications are auto-generated in my app.

Closed this issue · 4 comments

How can we help?

When I close the app and open it again, the notifications are generated again, such as correctly controlling that the push is not generated again if the backend is no longer sending me anything.

Code of Conduct

  • I agree to follow this project's Code of Conduct

photo_5069318705577569127_w

**Auto regenerated notifications on.

@RuHuaytaMars when you close your app do the notifications disappear from the Notification Shade? (This happens if the app is "force stopped")
If this is the case then OneSignal restores the notification as they end-user never interacted with it, this way they don't miss the notification. If the end-user swipes away the notification or taps on it it should not restore.

Correct, what happens is that the flow of my application is an app for taxi services, that is, for each tracking status a notification is displayed whether the customer interacts with the notification or not, it disappears when it changes status as it could do so that when changing the status that push no longer appears.

... it disappears when it changes status as it could do so that when changing the status that push no longer appears.

By the notification disappears is that your code is dismissing the notification? If so, make sure you use OneSignal.Notifications.removeNotification(id) so the OneSignal SDK knows that your app indented for notification to be dismissed, so it won't restore it.

If you don't want to display the notification if it arrives late (such as the device losses connection) I recommend setting a short TTL on the notification. The TTL is also respected in the notification restore logic too.

If there are other scenarios not covered above you can setup the OneSignal Android Notification Service Extension so you can control if the notification will show based on any logic you wish.