删除应用程序然后重新安装时的 iOS 推送通知行为 [英] iOS push notifications behavior when app is deleted and then reinstalled

查看:53
本文介绍了删除应用程序然后重新安装时的 iOS 推送通知行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到过一种不寻常的情况,即当我的应用被删除然后重新安装时,用户继续收到通知.场景如下:

  • 用户从应用商店安装应用
  • 用户登录我们的应用程序,我们为他们注册通知
  • 用户从他们的设备中删除应用
  • 用户从应用商店重新安装应用
  • 即使用户尚未启动应用程序、登录等,也会收到通知

我对 APNs 架构的理解是,一旦您的应用从您的设备中删除,操作系统本身就会从 APNs 中取消注册.在您调用registerForRemoteNotificationTypes"之前,重新安装应用程序不会重新启用通知——因此,如果使用旧令牌将便笺发送到设备,APN 将不会传送它,因为尚未调用上述方法.

这不准确吗?

解决方案

令牌保持不变.设备上的所有应用程序甚至都一样.它仅在您更改操作系统版本时更改.但是,这仍然不能解释您遇到的奇怪行为.

我相信只有在 Apple 确定应用程序已从设备上卸载后(通常在设备卸载后向特定设备上的应用程序发送通知时才会发生这种情况),它才会取消注册该应用程序.如果在卸载时和重新安装时之间没有向卸载应用程序的设备上的应用程序发送通知,则 Apple 不知道该设备卸载了该应用程序,因此它仍然注册了 APNS.

反馈服务的行为支持我的理论——如果你卸载应用程序并调用反馈服务,你将不会获得卸载应用程序的设备的设备令牌.只有在您尝试向该设备发送通知后,Apple 才会检测到卸载并在反馈服务中返回该设备令牌.

我应该添加的最后一件事 - 如果卸载的应用程序是设备上最后一个注册推送通知的应用程序,APN 服务将永远不会知道该应用程序已被卸载,因此它仍然会在之后注册 APN正在重新安装.

I've encountered an unusual scenario where a user is continuing to receive notifications when my app has been deleted and then reinstalled. The scenario is as follows:

  • user installs the app from the appstore
  • user logs onto our app and we register them for notifications
  • user deletes the app from their device
  • user reinstalls the app from the appstore
  • user receives a notification even though they have not started the app up yet, logged in, etc

My understanding of the APNs architecture was that once your app is deleted from your device, it is de-registered from APNs by the OS itself. A reinstall of the app would not re-enable notifications until you called "registerForRemoteNotificationTypes" -- so if a note was sent to the device using the old token, APNs would not deliver it since the above method has not been called.

Is that not accurate?

解决方案

The token remains the same. It's even the same for all applications on the device. It only changes when you change the OS version. However, that still doesn't explain the strange behavior you encountered.

I believe that only after Apple identifies that the application has been uninstalled from the device (which usually happens when you send a notification to the app on a specific device after the device uninstalled it) it un-registers the app. If no notifications were sent to the app on the device that uninstalled the app between the time of uninstall and the time of the new installation, Apple don't know the device uninstalled the app, and therefore it is still registered for APNS.

The behavior of the feedback service supports my theory - if you uninstall the app and call the feedback service, you won't get the device token of the device that uninstalled the app. Only after you try to send a notification to that device, Apple will detect the uninstall and return that device token in the feedback service.

One last thing I should add - if the uninstalled app is the last one on the device that was registered for push notifications, the APN service will never know that the app was uninstalled, and therefore it will still be registered for APN after being re-installed.

这篇关于删除应用程序然后重新安装时的 iOS 推送通知行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆