【问题标题】:Push notification not determined未确定推送通知
【发布时间】:2016-12-27 14:13:30
【问题描述】:

在 ios 10 中有 UNUserNotificationCenter 类和方法 getNotificationSettingsWithCompletionHandler 为您提供 UNNotificationSettings 对象,您可以检查用户是否曾被要求提供推送通知权限。有没有办法在 iOS 9 和iOS 8。

【问题讨论】:

    标签: ios ios8 apple-push-notifications unusernotificationcenter


    【解决方案1】:

    你可以这样使用:

    let notificationType = UIApplication.sharedApplication().currentUserNotificationSettings()!.types
    
    if notificationType == UIUserNotificationType.None {
      // Push notifications are disabled in setting by user.
    } else {
     // Push notifications are enabled in setting by user.
    }
    
    if notificationType != UIUserNotificationType.None {
      // Push notifications are enabled in setting by user.
    }
    
    if notificationType == UIUserNotificationType.Badge {
      // the application may badge its icon upon a notification being received
    }
    
    if notificationType == UIUserNotificationType.Sound {
      // the application may play a sound upon a notification being received
    }
    
    if notificationType == UIUserNotificationType.Alert {
      // the application may display an alert upon a notification being received
    }
    

    【讨论】:

      【解决方案2】:

      没有办法。该功能从 ios 10 开始可用。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-07-17
        • 2015-12-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-04-11
        相关资源
        最近更新 更多