如何取消“允许推送通知”对话框一次?(How to get back “Allow Push Notifications” dialog after it was dismissed once?)

编程入门 行业动态 更新时间:2024-10-25 19:25:56
如何取消“允许推送通知”对话框一次?(How to get back “Allow Push Notifications” dialog after it was dismissed once?)

我正在构建一个非常依赖APN的应用程序。 在我的应用程序第一次启动时,iOS会询问这个应用程序是否允许使用APN(作为registerForRemoteNotificationTypes: call的结果)。 但是一旦被解雇,这个对话框永远不会弹出。 我必须手动去Settings->Notifications->MyApp启用/禁用那里的东西。 那么有一种方法可以避免这种喧嚣,实际上每次在调试模式下启动我的应用程序时,都会体会到用户在第一次启动时会体验到什么?

I am building an app that is heavily relies on APN. Upon the very first start of my app, iOS asks if this app is allowed to use APN (as a result of registerForRemoteNotificationTypes: call). However once dismissed, this dialog is never popping up back. I have to manually go to Settings->Notifications->MyApp to enable/disable things there. So is there a way to avoid this hustle and actually experience what user will experience upon the very first start every time I start my app in debug mode?

最满意答案

苹果说你可以这样做:

重置iOS上的推送通知权限提醒

第一次推送应用程序注册推送通知时,iOS会询问用户是否希望收到该应用的通知。 一旦用户对此提醒做出了回应,除非恢复设备或应用程序已卸载至少一天,否则不会再显示该警报。

如果要模拟应用程序的首次运行,可以将应用程序卸载一天。 您可以实现后者,而不需要按照以下步骤实际上等待一天:

从设备中删除您的应用程序。

关闭设备完全关闭,然后重新打开。

转到设置>常规>日期和时间,并将日期提前一天或更长时间。

再次关闭设备,然后重新打开。

Here's how Apple say you can do it:

Resetting the Push Notifications Permissions Alert on iOS

The first time a push-enabled app registers for push notifications, iOS asks the user if they wish to receive notifications for that app. Once the user has responded to this alert it is not presented again unless the device is restored or the app has been uninstalled for at least a day.

If you want to simulate a first-time run of your app, you can leave the app uninstalled for a day. You can achieve the latter without actually waiting a day by following these steps:

Delete your app from the device.

Turn the device off completely and turn it back on.

Go to Settings > General > Date & Time and set the date ahead a day or more.

Turn the device off completely again and turn it back on.

更多推荐

本文发布于:2023-07-04 10:07:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1023067.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:对话框   通知   Push   dismissed   dialog

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!