APNs - 警报未显示

时间:2011-12-08 17:39:36

标签: iphone alert apple-push-notifications

我遇到以下问题,与iPhone上的Apple推送通知服务有关:如果远程通知到达时应用程序处于后台,则不会显示警报。

我知道通知正在到达设备,因为:1)如果有效负载包含任何内容,则显示徽章或播放声音; 2)如果应用程序位于前台,则调用方法-application:didReceiveRemoteNotification: userInfo上的适当值。

我注意到在设备上的通知设置中,我的应用只有选项徽章声音,而其他应用也有警报选项。我的猜测是我的应用程序以某种方式禁用了警报,但我不知道如何启用它。

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

检查您的appDelegate didFinishLaunchingWithOptions或didFinishLaunching方法中是否已注册 UIRemoteNotificationTypeAlert

它看起来应该是这样的:

 [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
 (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | 
  UIRemoteNotificationTypeAlert)];
  • UIRemoteNotificationTypeBadge - 启用徽章。
  • UIRemoteNotificationTypeSound - 启用声音。
  • UIRemoteNotificationTypeAlert - 启用警报。

另一个不太合理的是,您可能会在设备偏好设置中停用通知中心的“提醒”。

相关问题