iOS:应用程序未出现在“设置”的通知中心中
我有一个应用程序,允许在活动日期临近时通过通知中心向用户发送警报。但是,当我在设备上运行该应用程序时,我转到“设置”中的“通知”选项卡,但我的应用程序没有出现在其中。我还在底部的应用程序委托中的 didFinishLaunchingWithOptions:
方法中添加了此代码,我认为它可以解决问题:
[[UIApplication sharedApplication]
registerForRemoteNotificationTypes:
UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeSound];
我知道该代码通常仅用于推送通知,但是显然,此代码会提示用户询问他们是否要打开通知,而不是默认情况下在安装应用程序时关闭通知。
我是否应该添加任何其他代码以使其显示在“设置”的“通知”选项卡中?
谢谢你!
I have an app that allows sends the user an alert through the notification center when an event date is approaching. But, when I run the app on my device, I go to the "Notifications" tab in the Settings, and my application doesn't appear in there. I also added this code in my didFinishLaunchingWithOptions:
method in the App Delegate at the bottom, and I thought it would do the trick:
[[UIApplication sharedApplication]
registerForRemoteNotificationTypes:
UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeSound];
I'm aware that the code is usually only used for push notifications, but apparently this code prompts the user asking them if they would like to turn notifications on, rather than installing the app with them off by default.
Is there any other code that I should be adding to make it appear in the Notifications tab in the Settings?
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
评论(2)
检查您是否确实可以注册远程通知 - 在应用程序委托中您应该实现 2 个方法:
- (void)application:(UIApplication*)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
如果
- (void)application:(UIApplication*)application
didFailToRegisterForRemoteNotificationsWithError:(NSError*)error
调用第二个方法,则表示出现问题。
检查您的个人资料并阅读本教程
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
在开发门户中,确保为您的应用程序 ID 配置推送通知。配置完成后,您需要下载并安装修改后的配置文件。
In the development portal, make sure that push notifications is configured for your App ID. Once that's configured, you'll need to download and install the modified profile.