xcode iOS:应用程序未出现在设置中的通知中心

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8945758/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 23:03:00  来源:igfitidea点击:

iOS: App Not Appearing In Notification Center In Settings

iphoneiosxcodenotificationssettings

提问by Henry F

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:

我有一个应用程序,当活动日期临近时,它允许通过通知中心向用户发送警报。但是,当我在我的设备上运行该应用程序时,我转到“设置”中的“通知”选项卡,而我的应用程序没有出现在那里。我还在didFinishLaunchingWithOptions:底部的 App Delegate 的方法中添加了这段代码,我认为它可以解决问题:

    [[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!

谢谢!

回答by picciano

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.

在开发门户中,确保为您的 App ID 配置推送通知。配置完成后,您需要下载并安装修改后的配置文件。

回答by Pavel Oganesyan

Check if you actually can register for remote notifications - in app delegate you should implement 2 methods:

检查您是否真的可以注册远程通知 - 在应用程序委托中,您应该实现两种方法:

- (void)application:(UIApplication*)application
   didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken

and

- (void)application:(UIApplication*)application
   didFailToRegisterForRemoteNotificationsWithError:(NSError*)error

If the second one is called, something gone bad. Check your profiles and read this tutorial

如果第二个被调用,事情就变糟了。检查您的个人资料并阅读本教程