【问题标题】:IOS 7 determine if "Show in Notification Center" is disabledIOS 7确定“在通知中心显示”是否被禁用
【发布时间】:2023-04-02 09:33:01
【问题描述】:

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

UIRemoteNotificationType notificationType =  [[UIApplication sharedApplication] enabledRemoteNotificationTypes];

if (!(notificationType & UIRemoteNotificationTypeAlert))
{

}

当我设置时

设置 -> 通知 -> 应用名称 -> “在通知中显示 居中”为是

并选择警报类型以通知我得到 UIRemoteNotificationTypeAlert 的通知类型

当我设置时

设置 -> 通知 -> 应用名称 -> “在通知中显示 居中”为否

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

“在通知中心显示”

设置为否?

【问题讨论】:

    标签: ios ios7 notifications


    【解决方案1】:

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

    你可以这样称呼:

    UIRemoteNotificationType types = [UIApplicationsharedApplication].enabledRemoteNotificationTypes;
    

    在您的UIRemoteNotificationType 中给出以下枚举:

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

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

    【讨论】:

    • iOS10怎么样? @Abhinav
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-20
    • 2014-02-25
    • 2020-01-01
    相关资源
    最近更新 更多