IOS 7确定是否"在通知中心显示"被禁用

时间:2015-10-01 12:37:58

标签: ios ios7 notifications

我正在使用以下代码来确定用户是否启用了警报通知

UIRemoteNotificationType notificationType =  [[UIApplication sharedApplication] enabledRemoteNotificationTypes];

if (!(notificationType & UIRemoteNotificationTypeAlert))
{

}

当我设置

  

设置 - >通知 - > Appname - > "在通知中显示   中心"是的

并选择警报类型以警报我获取notificationType

的UIRemoteNotificationTypeAlert

当我设置

  

设置 - >通知 - > Appname - > "在通知中显示   中心"没有

仍然可以获得notificationType的UIRemoteNotificationTypeAlert。有没有办法确定是否

  

"在通知中心显示"

设为NO?

1 个答案:

答案 0 :(得分:1)

简单回答 - 这不能以编程方式完成。

你可以这样称呼:

UIRemoteNotificationType types = [UIApplicationsharedApplication].enabledRemoteNotificationTypes;

UIRemoteNotificationType中提供以下枚举:

typedef enum 
{    
  UIRemoteNotificationTypeNone    = 0,   
  UIRemoteNotificationTypeBadge   = 1 << 0,   
  UIRemoteNotificationTypeSound   = 1 << 1,   
  UIRemoteNotificationTypeAlert   = 1 << 2,   
  UIRemoteNotificationTypeNewsstandContentAvailability = 1 << 3 
}

因此,您可以了解用户启用的通知类型,但不知道用户是否为您的应用启用或停用了通知中心。

相关问题