ios 如何再次显示“Would like to send you Push Notifications” Alert View?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8033216/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to show "Would like to send you Push Notifications" Alert View again?
提问by Vincent Bacalso
I was able to show an Alert View like the image above after registering for Remote Notifications. But when i delete my Project App and build it again, it will not show anymore.
注册远程通知后,我能够显示如上图所示的警报视图。但是当我删除我的项目应用程序并重新构建它时,它将不再显示。
Will there be any chances to show the alert view again to the same device?
是否有机会再次向同一设备显示警报视图?
What i like is to get my device token again because I failed to store the device token temporarily in the NSUserDefaults.
我喜欢的是再次获取我的设备令牌,因为我未能将设备令牌临时存储在 NSUserDefaults 中。
采纳答案by XJones
At launch, your app should be requesting a token via:
在启动时,您的应用应通过以下方式请求令牌:
- (void)registerForRemoteNotificationTypes:(UIRemoteNotificationType)types
and will get a token from iOS in the delegate message:
并将在委托消息中从 iOS 获取令牌:
– application:didRegisterForRemoteNotificationsWithDeviceToken:
iOS will prompt the user to allow notifications only when necessary. If remote notifications are already authorized for your app the alert will not appear and your app will get a valid token.
iOS 将提示用户仅在必要时允许通知。如果您的应用程序已授权远程通知,则不会出现警报,您的应用程序将获得有效令牌。
Net is you can't force the alert but you don't need to.
Net 是你不能强制警报,但你不需要。
回答by user2387149
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.
从设备中删除您的应用程序。
完全关闭设备并重新打开。
前往“设置”>“通用”>“日期与时间”,然后将日期提前一天或更长时间。
再次完全关闭设备并重新打开。
reference: https://developer.apple.com/library/ios/technotes/tn2265/_index.html
参考:https: //developer.apple.com/library/ios/technotes/tn2265/_index.html
回答by rondoagogo
Addressing the question of presenting the push notifications permissions dialog again as needed for testing -- this is certainly a workaround, but here goes:
解决根据测试需要再次显示推送通知权限对话框的问题——这当然是一种解决方法,但这里是:
Having just finished work on an app that uses Push Notifications extensively, and having tried all the usual permutations, without success ... I ultimately realized that the most streamlined way to work around that issue was to get a device to use only for testing (i.e., a low-end iPod Touch).
刚刚完成了一个广泛使用推送通知的应用程序的工作,并尝试了所有常见的排列,但没有成功......我最终意识到解决该问题的最简化方法是让设备仅用于测试(即,低端 iPod Touch)。
To reset the dialog, do a Settings > General > Reset > Erase All Content and Settings. Go thru the device's setup process, reinstall the app and Go.
要重置对话框,请执行“设置”>“常规”>“重置”>“删除所有内容和设置”。完成设备的设置过程,重新安装应用程序并开始。
This was the only way I found to test the 'first launch' experience on demand, as needed during the course of development/testing. It also added a lot of additional versatility to the process.
这是我发现在开发/测试过程中根据需要测试“首次发布”体验的唯一方法。它还为该过程增加了许多额外的多功能性。
Shouldn't have needed to resort to all this, but I'm very glad I did, as it turned out to be a real godsend. FWIW.
不应该诉诸所有这些,但我很高兴我做到了,因为结果证明这是一个真正的天赐之物。FWIW。
[P.S. It will probably also prove handy in the future for testing beta versions of the OS, etc.]
[PS 将来也可能会证明它对测试操作系统的 Beta 版本等很方便。]
回答by perezda
Yes.
是的。
http://developer.apple.com/library/ios/#technotes/tn2265/_index.html
http://developer.apple.com/library/ios/#technotes/tn2265/_index.html
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 setting the system clock forward a day or more, turning the device off completely, then turning the device back on.
如果您想模拟应用程序的首次运行,您可以将应用程序卸载一天。您可以通过将系统时钟提前一天或更多,完全关闭设备,然后重新打开设备来实现后者,而无需实际等待一天。
回答by Tom
Temporarily change your package id.
暂时更改您的包裹 ID。
com.mycompany.app - > com.mycompany.app1
com.mycompany.app - > com.mycompany.app1