How can I check if a device has activated push notifications ?
When users reach a certain view in my app, I’d like to check if their device has already accepted push notifications, and then, if no, show a sheet to pre-prompt them before running the “request push notification permission” action.
The search for current user’s device count should be one way to do it. We have it on our radar to add other permissions checks like location services too though
I’ve played around for the last few hours and have found limitations.
I’ve tried different expressions starting with “current user’s device” and then with the operator “push notification token” but with no success.
I ran a test while logged in into my app and I thought "current user's devices each item push notification count > 0 was working to know if push notifications were granted
But then, I uninstalled the app, installed it again, and logged back in. At this point, push notifications are not granted and no new device is created. But my previous devices (which were not deleted as I uninstalled the app) still contain a token, so my app thinks notifications are granted, when they are not.
Also, tons of users are going to use our apps without being logged in, and If a logged out user activates push notifications, it’s impossible to perform any check because the field “current user” field in the device datatype is blank.
I think an expression to check “current device has activated push notifications” is as much, (if not more!) important than the “has granted location permission” expression.