UNUserNotificationCenter
2019-03-05 本文已影响0人
风冰武
//iOS 10有用 22行
typedef NS_OPTIONS(NSUInteger, UNAuthorizationOptions) {
UNAuthorizationOptionBadge, //边角
UNAuthorizationOptionSound, //声音
UNAuthorizationOptionAlert ,
UNAuthorizationOptionCarPlay,
UNAuthorizationOptionCriticalAlert,
UNAuthorizationOptionProvidesAppNotificationSettings,
UNAuthorizationOptionProvisional,
};
//管理通知的对象 37行
@interface UNUserNotificationCenter : NSObject
备注: iOS 10之后才可以使用
//返回通知中心对象 46行
//返回: 通知中心对象
+ (UNUserNotificationCenter *)currentNotificationCenter;
//当本地通知和远程通知传递到用户的设备时, 请求授权与用户交互 51行
//参数1: 请求的授权选项
//参数2: 与结果异步执行的块(参数: granted: 是否授权, error:错误)
- (void)requestAuthorizationWithOptions:(UNAuthorizationOptions)options completionHandler:(void (^)(BOOL granted, NSError *__nullable error))completionHandler;