我正在使用以下代码来确定用户是否启用了警报通知
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/