简体   繁体   English

如何在iOS模拟器中重置推送通知权限?

[英]How do I reset push notification permissions in iOS simulator?

I'm developing push notifications for an iOS app. 我正在为iOS应用开发推送通知。

How do I reset the push notification permissions on an iOS simulator? 如何在iOS模拟器上重置推送通知权限?

I've read this question: Push Notification iOS resetting 我读过这个问题: 推送通知iOS重置

As per the Q&A above, I'm aware that you can't reset them easily on a normal phone. 根据上述问答,我知道您无法在普通手机上轻松重置它们。 But obviously there must be a way to develop around this feature (I hope). 但是显然必须有一种方法可以围绕此功能进行开发(我希望)。 I'm using a simulator. 我正在使用模拟器。 This is all just fluff text because the question is actually really simple but if you make a question too short, people think you haven't done your research. 这只是毛茸茸的文字,因为问题实际上很简单,但是如果您提出的问题太短,人们就会认为您尚未完成研究。 There is a certain length at which a question appears legitimate, and I think I've finally reached it. 一个问题在一定程度上似乎是合理的,我想我终于解决了。 To reiterate: 重申:

How do I reset the push notification permissions on an iOS simulator? 如何在iOS模拟器上重置推送通知权限?

The only way I've found so far is to select from the top menu Hardware > Erase all content and settings... , but this makes for a pretty slow dev cycle. 到目前为止,我发现的唯一方法是从顶部菜单中选择“ Hardware > Erase all content and settings... ,但这会使开发周期非常缓慢。

Well, that's the easiest and fastest thing you could do to reset the asking of every permissions in your app in simulator. 嗯,这是您可以最简单,最快的方法来重置模拟器中应用程序中每个权限的询问。 Hardware > Erase all content and settings . Hardware > Erase all content and settings

But why? 但为什么? Why do you need to do that? 为什么需要这样做? The much faster way is to write a Unit Test to test your function in handling the time the user grants or declines the asking of permission of your app. 更快的方法是编写一个Unit Test来测试您在用户授予或拒绝您的应用程序许可请求的时间方面的功能。

OR if you don't feel like writing tests, just put a mock variable or something that would mock the Allow and Don't Allow events. 或者,如果您不想编写测试,只需放置一个模拟变量或将模拟“ 允许”“不允许”事件的内容即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM