iOS10通知框架UserNotification理解与应用

2020-01-18 16:20:19于海丽

2.UNNotification类


@interface UNNotification : NSObject <NSCopying, NSSecureCoding>
//触发的时间
@property (nonatomic, readonly, copy) NSDate *date;
//内置的通知请求对象
@property (nonatomic, readonly, copy) UNNotificationRequest *request;

- (instancetype)init NS_UNAVAILABLE;

@end

3.UNNotificationSettings类

        UNNotificationSettings类主要用来获取与通知相关的信息。


@interface UNNotificationSettings : NSObject <NSCopying, NSSecureCoding>
//用户权限状态
@property (NS_NONATOMIC_IOSONLY, readonly) UNAuthorizationStatus authorizationStatus;
//音效设置
@property (NS_NONATOMIC_IOSONLY, readonly) UNNotificationSetting soundSetting __TVOS_PROHIBITED;
//图标提醒设置
@property (NS_NONATOMIC_IOSONLY, readonly) UNNotificationSetting badgeSetting __WATCHOS_PROHIBITED;
//提醒框设置
@property (NS_NONATOMIC_IOSONLY, readonly) UNNotificationSetting alertSetting __TVOS_PROHIBITED;
//通知中心设置
@property (NS_NONATOMIC_IOSONLY, readonly) UNNotificationSetting notificationCenterSetting __TVOS_PROHIBITED;
//锁屏设置
@property (NS_NONATOMIC_IOSONLY, readonly) UNNotificationSetting lockScreenSetting __TVOS_PROHIBITED __WATCHOS_PROHIBITED;
//车载设备设置
@property (NS_NONATOMIC_IOSONLY, readonly) UNNotificationSetting carPlaySetting __TVOS_PROHIBITED __WATCHOS_PROHIBITED;
//提醒框风格
@property (NS_NONATOMIC_IOSONLY, readonly) UNAlertStyle alertStyle __TVOS_PROHIBITED __WATCHOS_PROHIBITED;

@end

UNNotificationSetting枚举如下:


typedef NS_ENUM(NSInteger, UNNotificationSetting) {
  //不支持
  UNNotificationSettingNotSupported = 0,
  
  //不可用
  UNNotificationSettingDisabled,
  
  //可用
  UNNotificationSettingEnabled,
} 

UNAuthorizationStatus枚举如下:


typedef NS_ENUM(NSInteger, UNAuthorizationStatus) {
  //为做选择
  UNAuthorizationStatusNotDetermined = 0,
  
  // 用户拒绝
  UNAuthorizationStatusDenied,
  
  // 用户允许
  UNAuthorizationStatusAuthorized
}

UNAlertStyle枚举如下:


typedef NS_ENUM(NSInteger, UNAlertStyle) {
  //无
  UNAlertStyleNone = 0,
  //顶部Banner样式
  UNAlertStyleBanner,
  //警告框样式
  UNAlertStyleAlert,
}

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持ASPKU。


注:相关教程知识阅读请移步到IOS开发频道。