1
votes

We want to send push notifications in Android and iOS to a group of users that match a certain condition. We can check if an user match this condition calling an API.

Our problem is that the users information changes very quickly and we don't have any way to keep track of this in our push notifications engine (OneSignal).

The only alternative we can think is to send the push notification to all users and client side call the API to get the latest user information. Depending on this we could choose to show the notification or ignore it.

Is this possible on Android and iOS?

2

2 Answers

0
votes

It is 100% possible for sure. in the receiver class you call an intentservice, which can hit an api and get the latest information, based on the information you create notification using notification builder, and avoid if you dont want.

0
votes

Yes, with the help of NotificationExtenderService this is possible.

Receive a notification in the background. Notification data is wrapped up in OSNotificationReceivedResult object. Now, read the notification id/title which should be unique for every notification.

Send this unique notification title/id along with user id to an API, which will return whether to show the notification to the user or not. If true then read notification title and message/description from OSNotificationReceivedResult and make a notification via NotificationCompat otherwise just ignore it.

Reference