检索已获取的推送通知令牌

发布于 2024-12-21 03:30:46 字数 437 浏览 5 评论 0原文

我们正在开发一个应该接收推送通知的应用程序。在我们的测试设备上,当系统提示我们“确定”发送通知时,我们单击“确定”,但未能存储收到的令牌。 (我们端对服务器的请求没有得到正确处理,并且令牌没有被我们存储在其他任何地方)。

我们尝试了以下方法来再次触发 didRegisterForRemoteNotificationsWithDeviceToken 函数(无济于事):

  • 完全删除该应用程序并重新安装
  • 在 iPhone 设置中关闭我们应用程序的通知

但是,我们无法让它再次“提示”我们,并且 APN开发服务器似乎已经注册,所以我假设这就是 didRegisterForRemoteNotificationsWithDeviceToken 不会再次触发的原因。

最终我们无法获得新的令牌,并且我不知道如何检索已经注册的令牌。有谁知道如何检索已经注册的令牌?

We are working on an app that is suposed to receive push notifications. On our test device when we were prompted for an ok to send notifications we clicked ok but failed to store the token that we received. (The request to the server on our end was not handled properly and the token was not stored anywhere else by us).

We have tried the following to have the function didRegisterForRemoteNotificationsWithDeviceToken trigger again (to no avail):

  • Completely remove the app and reinstall
  • Turn off notifications for our app in the iPhone settings

However, we cant get it to 'prompt' us again, and the APN development server seems to have already registered so I am assuming that is why the didRegisterForRemoteNotificationsWithDeviceToken doesnt trigger again.

In the end we cannot get a new token, and I don't know how to retrieve the already registered token. Does anyone know how to retrieve the already registered token?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

最近可好 2024-12-28 03:30:46
  1. 如果您每次启动应用程序时都调用 UIApplication 的 registerForRemoteNotificationTypes: 方法,则 application:didRegisterForRemoteNotificationsWithDeviceToken: 委托方法每次也会被调用。第一次注册时,iOS 会询问用户是否想要接收通知,iOS 连接 Apple 通知服务来注册并获取设备令牌。之后,registerForRemoteNotificationTypes:方法调用既不会询问用户也不会连接APN,iOS将立即使用已注册的令牌调用委托方法。

  2. 如果您希望应用程序启动时再次询问用户

一些相关的详细信息:iOS 应用程序客户端设备令牌管理与 Apple 推送通知

  1. if you call registerForRemoteNotificationTypes: method of UIApplication every time your application launch, the application:didRegisterForRemoteNotificationsWithDeviceToken: delegate method will be called every time also. When the first time registration, iOS will ask user if they want receive notifications, and iOS connect the Apple Notification Service to register and get device token. After that, registerForRemoteNotificationTypes: method call will neither ask user nor connect APN, iOS will immediately call delegate method with the already registered token.

  2. if you want to the Application launching to ask user again, call the unregisterForRemoteNotifications , then call registerForRemoteNotificationTypes: method again.

some detail information related: iOS Application Client Side Device Token Management With Apple Push Notification

黯然#的苍凉 2024-12-28 03:30:46

我发现当应用程序完全关闭并再次启动时,应用程序总是会调用 didRegisterForRemoteTrigger,这将为您提供已经注册的令牌。我不确定为什么当我第一次尝试恢复令牌时它没有调用此方法,但这似乎是解决方案。

I found that the app will always call didRegisterForRemoteTrigger when the application is fully closed and started again, and this will give you the already registered token. I am not sure why it did not call this method when I first tried to recover the token, but this seems to be the solution.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文