繁体   English   中英

推送通知不显示

[英]Push notifications don't show up

我添加了用于接收远程通知的功能,但是该行为确实很奇怪。 当应用程序处于前台时,该方法

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {

正在被呼叫。 尽管当应用程序在后台运行时-没有任何显示。 我没有看到带有传入通知消息的横幅,并且“通知”下拉列表中没有任何内容。

还有一件奇怪的事情—该应用程序未显示在设备的“设置”->“通知应用程序”列表中。 我完全可以接受吗? 即使只是在后台?

有没有人遇到过类似的问题?

打开应用程序时,将在应用程序委托中调用didReceiveRemoteNotification方法,但不会显示警报。 仅当您的应用程序处于后台/非活动状态时,才会显示警报。 尽管您可以在应用程序中轻松创建一个UIAlertView,并在应用程序处于活动状态并收到推送通知时显示它。

最终,我自己解决了这些问题-我没有调用registerUserNotificationSettings ,所以不允许任何类型的通知。 现在,我这样做:

[application registerForRemoteNotifications];
UIUserNotificationType types = UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert;
UIUserNotificationSettings *mySettings = [UIUserNotificationSettings settingsForTypes:types categories:nil];
[application registerUserNotificationSettings:mySettings];

完美的作品!

暂无
暂无

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

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