DeviceNotRegistered not showing on iOS after uninstalling app

Please provide the following:

  1. SDK Version: 40.0.1
  2. Platforms(Android/iOS/web/all): Android/iOS
  3. Add the appropriate “Tag” based on what Expo library you have a question on.

Hi, I am trying to use best practices and not send notification to devices that are not registered anymore (either uninstalled app, or disabled notifications, etc). Doing so, I have noticed a difference in behavior on iOS vs Android. Apologize if this is somewhere in documentation, but on Android as soon as I uninstall the app and try and send a notification using the expo Push service, I get DeviceNotRegistered. When I do the same on iOS (version 11 and 13) I still get “ok” status on all receipts after the app was uninstalled, even after 15-30min have passed since the uninstall.

For Android, if I block the Notifications for the specific app, I still get “ok” status on those too.

My fear is that eventually I will have a lot of unknown cases when I should not be sending notifications, but I still am.

Any ideas how to detect / know not to send anymore notifications in this case?

Thanks

Hey @apps.eugene, how much time elapsed between you uninstalling the app on IOS and trying to send a notif? It can take some time before APNS returns the DeviceNotRegistered error.

Cheers,
Adam

I tried 15min after the uninstall, then 30min, then even 1hr and a few hours later and still got ok both the api/v2/push/send and api/v2/push/getReceipts endpoints. Did not try past 24hrs since the getReceipts won’t have those anymore.

Because of this, and because there is no way to know if a user uninstalled the app, I am not sure how to accurately stop sending notifications to users who are long gone and did not properly logged off my app.

I have also checked the logs for other existing iOS users that have not logged in for months now (I am sure some of them have deleted the app by now) and the receipts are still coming back with ok. So to my knowledge, from what I see, on iPhones we don’t ever get DeviceNotRegistered

try sending the notification directly via apns to see what the response is. the expo push service wraps this but doesn’t do anything particularly fancy over the responses, so it’s likely you’re just getting back what apple is giving us

Is there an easy way to do that from an expo token (from using expo push notifications) to do it directly via APN? Or it would have to be a new setup, a new install, new registrations with APN, and uninstall, etc

Sorry if dumb question, I have only been using your notifications setup as it’s simplified.

so looked at all the logs across the entire database and I only have DeviceNotRegistered for Android, tied to this only error The recipient device is not registered with FCM. I assume the iOS one would say something about APN and none of those at all… So confirms that it’s Android only again.

It is completely up to Apple (APNs) to decide when to report a device as unregistered. The push receipt from the Expo push notification service depends on whatever APNs responds with.

The DeviceNotRegistered error appears in push receipts only when Apple, Google, or another push notification provider deems the device to be unregistered; it takes an undefined amount of time and is often not possible to test by uninstalling your app and sending a push notification shortly after.

1 Like

Yea definitely seen that in the docs. But it’s just surprising that none of the iPhone we have ever reported that. Only Androids. So I just want to see if that’s even possible at all. Like has anyone ever gotten DeviceNotRegistered in their manage workflow projects with Expo Push Notifications?

Yes, APNs sends back responses saying devices are unregistered. I don’t know what the internal implementation within iOS and APNs is. It is possible that it may take several days or a month for a device to be considered unregistered irregardless of Expo.

So if that is the case, how would we detect that, since after 24hrs the Expo servers do not keep the receipt IDs anymore? Like if APN only tells me 2 days later that now we consider that device unregistered, but on the second day I get nothing from getReceipts … Calling APN directly is more of a solution for those using that setup to send notifications initially with and not Expo Push Service.

Push receipts communicate the message from Apple or Google. If Apple were to consider a device to be unregistered 30 days after the app is uninstalled, this is how things would work:

Day 1: the user uninstalls the app. You send push notification #1 to the device. APNs chooses not to report the device as unregistered. Push receipt #1 says the notification #1 was handed off to APNs successfully.
Day 2: push receipt #1 expires and is no longer available.

Day 31: You send push notification #2 to the device. APNs reports the device as unregistered. Push receipt #2 for this new notification says the device is unregistered.

Even if the Expo push notification service retained push receipts forever, the contents of push receipt #1 generally would not change even after APNs reports the device as unregistered. The push receipts aren’t dynamic and report back whatever the push provider says when attempting to send a notification to them.

What I have so far is basically what is in your example: that eventually if I try to send a notification to the unregistered device, it will report a correct status sooner within that 24hr window. It’s just a bit wasteful between day 2 and day 30 I guess and I hope APNs don’t complain about that part as spamming.

But the last part you said (about receipts aren’t dynamic) makes me more confused about the need for the push/getReceipts method. Like if I send a new notification via push/send and that already returns the receipt with DeviceNotRegistered, I can just use that to stop sending again. So what would be a use case for calling push/getReceipts later? I thought the reason for push/getReceipts is to check back again on the correctness of the status from that initial push/send step.

The Expo push notification service is a thin layer over APNs. A push receipt says a device is unregistered if and only if APNs reports the device as unregistered. There is no special Expo logic and everything related to whether a device is marked as unregistered applies whether or not you use Expo.

The push/send endpoint returns push tickets, not push receipts. A push ticket contains the ID of a future push receipt. We recommend you wait 15 minutes after calling push/send to check push/getReceipts and get the receipts. The official Expo docs cover push tickets and push receipts.

Got it. Thanks for clarification!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.