xcode 当我删除我的 iOS 应用程序推送通知状态保持
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12369900/
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
When I delete my iOS application push notification state remains
提问by Majid Laissi
When I install my iOS application using Xcode for the first time, my iPhone asks whether I want to enable push notifications.
当我第一次使用 Xcode 安装我的 iOS 应用程序时,我的 iPhone 会询问我是否要启用推送通知。
I am able to send a notification, and the badge shows a number that I sent.
我可以发送通知,并且徽章显示我发送的号码。
When I delete the application from my iPhone and rebuild it in Xcode and reinstall it again on my iPhone (using Xcode):
当我从我的 iPhone 中删除应用程序并在 Xcode 中重建它并在我的 iPhone 上重新安装它时(使用 Xcode):
- The device does not ask if I want to enable push.
- The badge is there and remembersthe last number.
- 设备不会询问我是否要启用推送。
- 徽章在那里并记住最后一个数字。
I tried the same application on a fresh device (installed the IPA) and it asked me for permissions.
我在新设备(安装了 IPA)上尝试了相同的应用程序,它要求我授予权限。
How can I completely make my device forget the application?
如何让我的设备完全忘记应用程序?
Thanks
谢谢
采纳答案by Justin
There is a workaround for this that involves setting the system time ahead by two days, rebooting the device, and then changing the system time back to the present. iOS is designed to only ask permission for push once a day per application.
有一种解决方法,包括将系统时间提前两天,重新启动设备,然后将系统时间改回当前。iOS 旨在为每个应用程序每天仅请求一次推送许可。
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 setting the system clock forward a day or more, turning the device off completely, then turning the device back on.
在 iOS 上重置推送通知权限警报 启用推送的应用程序首次注册推送通知时,iOS 会询问用户是否希望接收该应用程序的通知。一旦用户对此警报做出响应,除非设备恢复或应用程序已卸载至少一天,否则它不会再次出现。
如果您想模拟应用程序的首次运行,您可以将应用程序卸载一天。您可以通过将系统时钟提前一天或更多,完全关闭设备,然后重新打开设备来实现后者,而无需实际等待一天。
http://developer.apple.com/library/ios/#technotes/tn2265/_index.html
http://developer.apple.com/library/ios/#technotes/tn2265/_index.html
回答by Mike
Updated for iOS 7 and later from Apple's docs:
从 Apple 的文档中针对 iOS 7 及更高版本进行了更新:
On iOS 7 and later, 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.
在 iOS 7 及更高版本上,启用推送的应用程序第一次注册推送通知时,iOS 会询问用户是否希望接收该应用程序的通知。一旦用户对此警报做出响应,除非设备恢复或应用程序已卸载至少一天,否则它不会再次出现。
如果您想模拟应用程序的首次运行,您可以将应用程序卸载一天。您可以按照以下步骤实现后者,而无需等待一天:
- 从设备中删除您的应用程序。
- 完全关闭设备并重新打开。
- 前往“设置”>“通用”>“日期与时间”,然后将日期提前一天或更长时间。
- 再次完全关闭设备并重新打开。
For iOS 5 and iOS6:
对于 iOS 5 和 iOS6:
Reset the push notifications permissions alert by restoring the device from a backup (r. 11450187). Here are the steps to do this efficiently:
- Use the Xcode Organizer to install your app on the device. The key is to install the app for the first time without running it.
- Use iTunes to back up the device.
- Run the app. The push notifications permissions alert will be presented.
- When you want to reset the push notifications permissions alert, restore the device from the backup you created in the first step.
通过从备份恢复设备来重置推送通知权限警报 (r. 11450187)。以下是有效执行此操作的步骤:
- 使用 Xcode Organizer 在设备上安装您的应用程序。关键是第一次安装应用程序而不运行它。
- 使用 iTunes 备份设备。
- 运行应用程序。将显示推送通知权限警报。
- 当您想要重置推送通知权限警报时,请从您在第一步中创建的备份中恢复设备。
https://developer.apple.com/library/content/technotes/tn2265/_index.html
https://developer.apple.com/library/content/technotes/tn2265/_index.html
回答by Jake Alewel
I was in the same boat you were. What I found most helpful was to slightly change the bundle identifier.
我和你在同一条船上。我发现最有帮助的是稍微更改包标识符。
Example: Your bundle identifier is com.company.app. If you need to test enabling push notifications change the identifier to com.company.app1. It will install as a new app and have new push notification permission settings.
示例:您的捆绑标识符是 com.company.app。如果您需要测试启用推送通知,请将标识符更改为 com.company.app1。它将作为新应用安装并具有新的推送通知权限设置。
Just make sure to change it back when you're done testing.
只需确保在完成测试后将其改回即可。
回答by saadnib
First of all there is no relation in that iOS
remember push settings,badge
value and you are not getting push notification
. I am sure that there is some other issue. Yes, iOS
remembers push settings
and badge
value for an app. It asks for push confirmation when you first install on device . You can reset badge
value by calling setApplicationIconBadgeNumber:
首先,iOS
记住push settings,badge
值与您没有得到push notification
. 我确定还有其他问题。是的,应用程序的iOS
记忆push settings
和badge
价值。当您第一次在设备上安装时,它会要求推送确认。您可以badge
通过调用重置值setApplicationIconBadgeNumber:
if you want to reset push settings
then you can do it by reset all setting
of your device.
如果要重置,push settings
则可以通过重置所有setting
设备来完成。
回答by palaniraja
If you have any app initialization code (eg., copying/initializing db when there are no db available in documents folder. so you know it is reinstalled) you could reset the badge count to zero.
如果您有任何应用程序初始化代码(例如,当文档文件夹中没有可用的数据库时复制/初始化数据库。因此您知道它已重新安装),您可以将徽章计数重置为零。
Again, this could fail if the users are manually deleting the db file from package or if you dont have such initialize setup for your app.
同样,如果用户从包中手动删除 db 文件,或者如果您的应用程序没有这样的初始化设置,这可能会失败。
回答by Abhinav Singh
Follow following Steps to stimulate First time run of your app by these steps:
按照以下步骤通过以下步骤刺激您的应用程序的首次运行:
1). Delete your app from the device.
1)。从设备中删除您的应用程序。
2). Turn the device off completely and turn it back on.
2)。完全关闭设备并重新打开。
3). Go to Settings > General > Date & Time and set the date ahead a day or more.
3)。前往“设置”>“通用”>“日期与时间”,然后将日期提前一天或更长时间。
4). Turn the device off completely again and turn it back on.
4)。再次完全关闭设备并重新打开。