IOS 7判断 "Show in Notification Center"是否被禁用

标签 ios ios7 notifications

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

UIRemoteNotificationType notificationType =  [[UIApplication sharedApplication] enabledRemoteNotificationTypes];

if (!(notificationType & UIRemoteNotificationTypeAlert))
{

}

当我设置

Settings -> Notifications -> Appname -> "Show in Notification Center" to YES

然后选择警报类型来提醒我得到 UIRemoteNotificationTypeAlert for notificationType

当我设置

Settings -> Notifications -> Appname -> "Show in Notification Center" to NO

我仍然得到通知类型的 UIRemoteNotificationTypeAlert。有没有办法判断是否

"Show in Notification Center"

设置为否?

最佳答案

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

你可以这样称呼:

UIRemoteNotificationType types = [UIApplicationsharedApplication].enabledRemoteNotificationTypes;

它在您的 UIRemoteNotificationType 中提供以下枚举:

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

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

关于IOS 7判断 "Show in Notification Center"是否被禁用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32887812/

相关文章:

objective-c - 在选择时用自定义单元格替换标准 UITableViewCell

ios - 在 Itunes 连接中上传构建后更改 Bundle ID

ios - RTCICEConnectionFailed swift

Cordova Background Fetcher 插件不适用于 iOS

iphone - 替换弃用的 sizeWithFont :minFontSIze:actualFontSize in ios 7

ios - iOS 7 分隔图像中的 UISegmentedControl 在动画期间是错误的

ios - UICollectionView 中的动画滚动到项目并不总是有效

安卓 "Use ringtone volume for notifications"

amazon-web-services - 我需要根据 Amazon Athena 中查询返回的结果创建警报

java - 使通知可点击且不可销毁