Hi guys, how can I stop sending notifications when I close or uninstall the app? I use user_id to send from my PHP backend.
That will be quite hard to implement.
You could make the notification invisible (no text, no visible payload) so it only triggers your app in the background and then not handle it. But this would also mean that you have no visible notification on the OS when you app is running.
The other way would be to create a “ping” in your app that tells your backend when the app is open and used (maybe your app also creates enough requests that this doesn’t have to be an additional request). Then only send notifications to users that were active in the last 3 minutes or similar.
With one signal you can create user segments and add users to them by tags. For your case for example when user logout you can send a tag oneSignal.sendTag(‘user_inactive’, ‘yes’); Based on this tag add him to the specific segment
and then at your backend you can target only segments that you want to receive notifications.
Now for the case app uninstall i think no action is needed one signal takes care of that
but I can not combine tags and user_id, it is not allowed in onesignal
If instead of send tags you just setSubscription to false ?