美文网首页将来跳槽用
iOS 老司机带你看UserNotications 之一

iOS 老司机带你看UserNotications 之一

作者: 大兵布莱恩特 | 来源:发表于2016-09-18 16:41 被阅读362次

概述:UserNotifications 最新 iOS10 苹果推出的  UserNotifications框架(UserNotifications.framework)支持本地和远程通知的交付和处理。你使用这个框架的类来安排当地通知的交付基于特定的条件,如时间或地点。应用程序和扩展也用这个框架来接收并可能修改本地和远程通知当他们交付给用户的设备。

UNNotificationSettings 获取通知一些设置信息

1  UNAuthorizationStatus : 通知授权状态 ,是一个枚举类型

  notDetermined 没有声明 用户没有选择程序是否可能发布用户通知 

 denied 用户坚决的拒绝,应用程序不能授权和发送通知

 authorized 应用程序获取授权可以发送通知

2 UNNotificationSetting 表示某个功能是否支持使用,比如通知

case notSupported  // 这个应用程序不支持声音提醒,这个是你请求授权通知功能时没有传这个类型,比如 alert ,sound ,badge 缺少那个 那个状态就是  soundSetting = notSupported 

// The notification setting is turned off.

case disabled // 用户一开始是支持sound bagde alert 功能的 后来用户在手机设置-通知中心把这个应用某个支持类型给关闭了,所以这个功能也是不可用的,只需要重新打开才能使用

// The notification setting is turned on.

case enabled // 表示通知的这个类型是可以使用的,比如 soudSetting = enbaled 表示收到通知后有声音提示

open var alertStyle: UNAlertStyle { get }  // 通知横幅的样式,比如在手机顶部弹窗通知,获取在手机屏幕中间弹窗

case none 没有弹窗提示

case banner // 顶部横幅

case alert // 屏幕中间alert样式

// Notification categories can be used to choose which actions will be displayed on which notifications.    open func setNotificationCategories(_ categories: Set)

 设置通知策略,收到通知后怎么去处理这个通知

UNNotificationActionOptions 执行通知的一些策略

//  authenticationRequired 这一行动是否应该被执行前需要解锁。

public static var authenticationRequired: UNNotificationActionOptions { get }

// destructive 是否应该表示这个动作是破坏性的。类似于 删除按

public static var destructive: UNNotificationActionOptions { get }

//  这一行动是否应该导致前台应用程序启动。

public static var foreground: UNNotificationActionOptions { get }

好了,我是大兵布莱恩特,欢迎加入博主技术交流群,iOS 开发交流群

![QQ20180712-0.png](https://img.haomeiwen.com/i1155481/9b84a3a3fce64f61.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

相关文章

网友评论

    本文标题:iOS 老司机带你看UserNotications 之一

    本文链接:https://www.haomeiwen.com/subject/qvmyettx.html