亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 系統 > iOS > 正文

iOS10通知框架UserNotification理解與應用

2020-07-26 03:10:34
字體:
來源:轉載
供稿:網友

一、引言

        關于通知,無論與遠程Push還是本地通知,以往的iOS系統暴漏給開發者的接口都是十分有限的,開發者只能對標題和內容進行簡單的定義,至于UI展示和用戶交互行為相關的部分,開發者開發起來都十分困難。至于本地通知,iOS10之前采用的是UILocationNotification類,遠程通知有蘋果服務器進行轉發,本地通知和遠程通知其回調的處理都是通過AppDelegate中的幾個回調方法來完成。iOS10系統中,通知功能的增強是一大優化之處,iOS10中將通知功能整合成了一個框架UserNotification,其結構十分類似于iOS8中的UIWebView向WebKit框架整合的思路。并且UserNotification相比之前的通知功能更加強大,主要表現在如下幾點:

1.通知處理代碼可以從AppDelegate中剝離。

2.通知的注冊,設置,處理更加結構化,更易于模塊化開發。

3.UserNotification支持自定義通知音效和啟動圖。

4.UserNotification支持向通知內容中添加媒體附件,例如音頻,視頻。

5.UserNotification支持開發者定義多套通知模板。

6.UserNotification支持完全自定義的通知界面。

7.UserNotification支持自定義通知中的用戶交互按鈕。

8.通知的觸發更加容易管理。

從上面列舉的幾點就可以看出,iOS10中的UsreNotification真的是一個大的改進,溫故而知新,關于iOS之前版本本地通知和遠程通知的相關內容請查看如下博客:

本地推送:http://www.49028c.com/article/93602.htm。

遠程推送:http://www.49028c.com/article/92953.htm。

二、UserNotification概覽

        學習一個新的框架或知識模塊時,宏觀上了解其體系,大體上掌握其結構是十分必要的,這更有利于我們對這個框架或模塊的整體把握與理解。UserNotification框架中拆分定義了許多類、枚舉和結構體,其中還定義了許多常量,類與類之間雖然關系復雜,但脈絡十分清晰,把握住主線,層層分析,邊很容易理解和應用UserNotification框架。

        下圖中列舉了UserNotification框架中所有核心的類:

如圖中關系所示,UserNotification框架中的核心類列舉如下:

UNNotificationCenter:通知管理中心,單例,通知的注冊,接收通知后的回調處理等,是UserNotification框架的核心。

UNNotification:通知對象,其中封裝了通知請求。

UNNotificationSettings:通知相關設置。

UNNotificationCategory:通知模板。

UNNotificationAction:用于定義通知模板中的用戶交互行為。

UNNotificationRequest:注冊通知請求,其中定義了通知的內容和觸發方式。

UNNotificationResponse:接收到通知后的回執。

UNNotificationContent:通知的具體內容。

UNNotificationTrigger:通知的觸發器,由其子類具體定義。

UNNotificationAttachment:通知附件類,為通知內容添加媒體附件。

UNNotificationSound:定義通知音效。

UNPushNotificationTrigger:遠程通知的觸發器,UNNotificationTrigger子類。

UNTimeInervalNotificationTrigger:計時通知的觸發器,UNNotificationTrigger子類。

UNCalendarNotificationTrigger:周期通知的觸發器,UNNotificationTrigger子類。

UNLocationNotificationTrigger:地域通知的觸發器,UNNotificationTrigger子類。

UNNotificationCenterDelegate:協議,其中方法用于監聽通知狀態。

三、進行通知用戶權限申請與創建普通的本地通知

        要在iOS系統中使用通知,必須獲取到用戶權限,UserNotification框架中申請通知用戶權限需要通過UNNotificationCenter來完成,示例如下:

//進行用戶權限的申請[[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:UNAuthorizationOptionBadge|UNAuthorizationOptionSound|UNAuthorizationOptionAlert|UNAuthorizationOptionCarPlay completionHandler:^(BOOL granted, NSError * _Nullable error) {  //在block中會傳入布爾值granted,表示用戶是否同意  if (granted) {   //如果用戶權限申請成功,設置通知中心的代理   [UNUserNotificationCenter currentNotificationCenter].delegate = self;  }}];

申請用戶權限的方法中需要傳入一個權限內容的參數,其枚舉定義如下:

typedef NS_OPTIONS(NSUInteger, UNAuthorizationOptions) { //允許更新app上的通知數字 UNAuthorizationOptionBadge = (1 << 0), //允許通知聲音 UNAuthorizationOptionSound = (1 << 1), //允許通知彈出警告 UNAuthorizationOptionAlert = (1 << 2), //允許車載設備接收通知 UNAuthorizationOptionCarPlay = (1 << 3),};

獲取到用戶權限后,使用UserNotification創建普通的通知,示例代碼如下:

 //通知內容類 UNMutableNotificationContent * content = [UNMutableNotificationContent new]; //設置通知請求發送時 app圖標上顯示的數字 content.badge = @2; //設置通知的內容 content.body = @"這是iOS10的新通知內容:普通的iOS通知"; //默認的通知提示音 content.sound = [UNNotificationSound defaultSound]; //設置通知的副標題 content.subtitle = @"這里是副標題"; //設置通知的標題 content.title = @"這里是通知的標題"; //設置從通知激活app時的launchImage圖片 content.launchImageName = @"lun"; //設置5S之后執行 UNTimeIntervalNotificationTrigger * trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:5 repeats:NO]; UNNotificationRequest * request = [UNNotificationRequest requestWithIdentifier:@"NotificationDefault" content:content trigger:trigger]; //添加通知請求 [[UNUserNotificationCenter currentNotificationCenter] addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {   }];

效果如下面圖示:

             

四、通知音效類UNNotificationSound

        通知可以進行自定義的音效設置,其中方法如下:

//系統默認的音效+ (instancetype)defaultSound;//自定義的音頻音效/*注意,音頻文件必須在bundle中或者在Library/Sounds目錄下*/+ (instancetype)soundNamed:(NSString *)name __WATCHOS_PROHIBITED;

五、通知觸發器UNNotificationTrigger

        通知觸發器可以理解為定義通知的發送時間,UNNotificationTrigger是觸發器的基類,具體的觸發器由它的四個子類實現,實際上,開發者在代碼中可能會用到的觸發器只有三種,UNPushNotificationTrigger遠程推送觸發器開發者不需要創建使用,遠程通知有遠程服務器觸發,開發者只需要創建與本地通知有關的觸發器進行使用。

1.UNTimeIntervalNotificationTrigger

        UNTimeIntervalNotificationTrigger是計時觸發器,開發者可以設置其在添加通知請求后一定時間發送。

//創建觸發器 在timeInterval秒后觸發 可以設置是否循環觸發+ (instancetype)triggerWithTimeInterval:(NSTimeInterval)timeInterval repeats:(BOOL)repeats;//獲取下次觸發的時間點- (nullable NSDate *)nextTriggerDate;

2.UNCalendarNotificationTrigger

        UNCalendarNotificationTrigger是日歷觸發器,開發者可以設置其在某個時間點觸發。

//創建觸發器 設置觸發時間 可以設置是否循環觸發+ (instancetype)triggerWithDateMatchingComponents:(NSDateComponents *)dateComponents repeats:(BOOL)repeats;//下一次觸發的時間點- (nullable NSDate *)nextTriggerDate;

3.UNLocationNotificationTrigger

        UNLocationNotificationTrigger是地域觸發器,開發者可以設置當用戶進入某一區域時觸發。

//地域信息@property (NS_NONATOMIC_IOSONLY, readonly, copy) CLRegion *region;//創建觸發器+ (instancetype)triggerWithRegion:(CLRegion *)region repeats:(BOOL)repeats __WATCHOS_PROHIBITED;

六、為通知內容添加附件

        附件主要指的是媒體附件,例如圖片,音頻和視頻,為通知內容添加附件需要使用UNNotificationAttachment類。示例代碼如下:

 //創建圖片附件 UNNotificationAttachment * attach = [UNNotificationAttachment attachmentWithIdentifier:@"imageAttach" URL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"2" ofType:@"jpg"]] options:nil error:nil]; UNMutableNotificationContent * content = [UNMutableNotificationContent new]; //設置附件數組 content.attachments = @[attach]; content.badge = @1; content.body = @"這是iOS10的新通知內容:普通的iOS通知"; //默認的通知提示音 content.sound = [UNNotificationSound defaultSound]; content.subtitle = @"這里是副標題"; content.title = @"這里是通知的標題"; //設置5S之后執行 UNTimeIntervalNotificationTrigger * trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:5 repeats:NO]; UNNotificationRequest * request = [UNNotificationRequest requestWithIdentifier:@"NotificationDefaultImage" content:content trigger:trigger]; [[UNUserNotificationCenter currentNotificationCenter] addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {   }];

效果如下圖      

需要注意,UNNotificationContent的附件數組雖然是一個數組,但是系統的通知模板只能展示其中的第一個附件,設置多個附件也不會有額外的效果,但是如果開發者進行通知模板UI的自定義,則此數組就可以派上用場了。音頻附件界面如下:

需要注意,添加附件的格式和大小都有一定的要求,如下表格所示:

創建通知內容附件UNNotificationAttachment實例的方法中有一個options配置字典,這個字典中可以進行配置的鍵值對如下:

//配置附件的類型的鍵 需要設置為NSString類型的值,如果不設置 則默認從擴展名中推斷extern NSString * const UNNotificationAttachmentOptionsTypeHintKey __IOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);//配置是否隱藏縮略圖的鍵 需要配置為NSNumber 0或者1extern NSString * const UNNotificationAttachmentOptionsThumbnailHiddenKey __IOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);//配置使用一個標準的矩形來對縮略圖進行裁剪,需要配置為CGRectCreateDictionaryRepresentation(CGRect)創建的矩形引用extern NSString * const UNNotificationAttachmentOptionsThumbnailClippingRectKey __IOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);//使用視頻中的某一幀作為縮略圖 配置為NSNumber時間extern NSString * const UNNotificationAttachmentOptionsThumbnailTimeKey __IOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);

七、定義通知模板UNNotificationCategory

        聊天類軟件在iOS系統中,常常采用后臺推送的方式推送新消息,用戶可以在不進入應用程序的情況下,直接在左面回復通知推送過來的信息,這種功能就是通過UNNotificationCategory模板與UNNotificationAction用戶活動來實現的。關于文本回復框,UserNotification框架中提供了UNTextInputNotificationAction類,其是UNNotificationAction的子類。示例代碼如下:

 //創建用戶活動 /* options參數可選如下: //需要在解開鎖屏下使用 UNNotificationActionOptionAuthenticationRequired //是否指示有破壞性 UNNotificationActionOptionDestructive //是否允許活動在后臺啟動app UNNotificationActionOptionForeground //無設置 UNNotificationActionOptionNone */ UNTextInputNotificationAction * action = [UNTextInputNotificationAction actionWithIdentifier:@"action" title:@"回復" options:UNNotificationActionOptionAuthenticationRequired textInputButtonTitle:@"活動" textInputPlaceholder:@"請輸入回復內容"]; //創建通知模板 UNNotificationCategory * category = [UNNotificationCategory categoryWithIdentifier:@"myNotificationCategoryText" actions:@[action] intentIdentifiers:@[] options:UNNotificationCategoryOptionCustomDismissAction]; UNMutableNotificationContent * content = [UNMutableNotificationContent new]; content.badge = @1; content.body = @"這是iOS10的新通知內容:普通的iOS通知"; //默認的通知提示音 content.sound = [UNNotificationSound defaultSound]; content.subtitle = @"這里是副標題"; content.title = @"這里是通知的標題"; //設置通知內容對應的模板 需要注意 這里的值要與對應模板id一致 content.categoryIdentifier = @"myNotificationCategoryText"; //設置5S之后執行 UNTimeIntervalNotificationTrigger * trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:5 repeats:NO];  [[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:[NSSet setWithObjects:category, nil]]; UNNotificationRequest * request = [UNNotificationRequest requestWithIdentifier:@"NotificationDefaultText" content:content trigger:trigger];  [[UNUserNotificationCenter currentNotificationCenter] addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {   }];

需要注意,要使用模板,通知內容UNNotificationContent的categoryIdentifier要與UNNotificationCategory的id一致。效果如下:

        也可以為通知模板添加多個自定義的用戶交互按鈕,示例如下:

UNNotificationAction * action = [UNNotificationAction actionWithIdentifier:@"action" title:@"活動標題1" options:UNNotificationActionOptionNone]; UNNotificationAction * action2 = [UNNotificationAction actionWithIdentifier:@"action" title:@"活動標題2" options:UNNotificationActionOptionNone]; UNNotificationAction * action3 = [UNNotificationAction actionWithIdentifier:@"action" title:@"活動標題3" options:UNNotificationActionOptionNone]; UNNotificationAction * action4 = [UNNotificationAction actionWithIdentifier:@"action" title:@"活動標題4" options:UNNotificationActionOptionNone];  UNNotificationCategory * category = [UNNotificationCategory categoryWithIdentifier:@"myNotificationCategoryBtn" actions:@[action,action2,action3,action4] intentIdentifiers:@[] options:UNNotificationCategoryOptionCustomDismissAction]; UNMutableNotificationContent * content = [UNMutableNotificationContent new]; content.badge = @1; content.body = @"這是iOS10的新通知內容:普通的iOS通知"; //默認的通知提示音 content.sound = [UNNotificationSound defaultSound]; content.subtitle = @"這里是副標題"; content.title = @"這里是通知的標題"; content.categoryIdentifier = @"myNotificationCategoryBtn"; //設置5S之后執行 UNTimeIntervalNotificationTrigger * trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:5 repeats:NO]; UNNotificationRequest * request = [UNNotificationRequest requestWithIdentifier:@"NotificationDefault" content:content trigger:trigger]; [[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:[NSSet setWithObjects:category, nil]]; [[UNUserNotificationCenter currentNotificationCenter] addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {   }];

需要注意,系統模板最多支持添加4個用戶交互按鈕,如下圖:

八、自定義通知模板UI

        通過前邊的介紹,我們發現通過UserNotification框架開發者已經可以完成許多從來很難實現的效果。然而這都不是UserNotification框架最強大的地方,UserNotification框架最強大的地方在于其可以完全自定義通知的UI界面。

        完全自定義通知界面是通過iOS擴展來實現的,首先創建一個新的target,如下圖:

選擇Notification Content,如下:

創建完成后,會發現工程中多了一個Notification Content的擴展,其中自帶一個storyboard文件和一個NotificationViewController類,開發者可以在storyboard文件或者直接在Controller類中進行自定義界面的編寫。

    需要注意,NotificationViewController自動遵守了UNNotificationContentExtension協議,這個協議專門用來處理自定義通知UI的內容展示,其中方法列舉如下:

//接收到通知時會被調用/*開發者可以從notification對象中拿到附件等內容進行UI刷新*/- (void)didReceiveNotification:(UNNotification *)notification;//當用戶點擊了通知中的用戶交互按鈕時會被調用/*response對象中有通知內容相關信息在回調block塊completion中,開發者可以傳入一個UNNotificationContentExtensionResponseOption參數來告訴系統如何處理這次用戶活動UNNotificationContentExtensionResponseOption枚舉中可選值如下:typedef NS_ENUM(NSUInteger, UNNotificationContentExtensionResponseOption) {  //不關閉當前通知界面  UNNotificationContentExtensionResponseOptionDoNotDismiss,  //關閉當前通知界面  UNNotificationContentExtensionResponseOptionDismiss,  //關閉當前通知界面并將用戶活動傳遞給宿主app處理  UNNotificationContentExtensionResponseOptionDismissAndForwardAction,} __IOS_AVAILABLE(10_0) __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE __OSX_UNAVAILABLE;*/- (void)didReceiveNotificationResponse:(UNNotificationResponse *)response completionHandler:(void (^)(UNNotificationContentExtensionResponseOption option))completion;/*這個屬性作為get方法進行實現 這個方法用來返回一個通知界面要顯示的媒體按鈕typedef NS_ENUM(NSUInteger, UNNotificationContentExtensionMediaPlayPauseButtonType) {  //不顯示媒體按鈕  UNNotificationContentExtensionMediaPlayPauseButtonTypeNone,  //默認的媒體按鈕 當點擊按鈕后 進行播放與暫停的切換 按鈕始終顯示  UNNotificationContentExtensionMediaPlayPauseButtonTypeDefault,  //Overlay風格 當點擊按鈕后,媒體播放,按鈕隱藏 點擊媒體后,播放暫停,按鈕顯示。  UNNotificationContentExtensionMediaPlayPauseButtonTypeOverlay,} __IOS_AVAILABLE(10_0) __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE __OSX_UNAVAILABLE;*/@property (nonatomic, readonly, assign) UNNotificationContentExtensionMediaPlayPauseButtonType mediaPlayPauseButtonType;//返回媒體按鈕的位置@property (nonatomic, readonly, assign) CGRect mediaPlayPauseButtonFrame;//返回媒體按鈕的顏色@property (nonatomic, readonly, copy) UIColor *mediaPlayPauseButtonTintColor;//點擊播放按鈕的回調- (void)mediaPlay;//點擊暫停按鈕的回調- (void)mediaPause;//媒體開始播放的回調- (void)mediaPlayingStarted __IOS_AVAILABLE(10_0) __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE __OSX_UNAVAILABLE;//媒體開始暫停的回調- (void)mediaPlayingPaused __IOS_AVAILABLE(10_0) __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE __OSX_UNAVAILABLE;

需要注意,自定義的通知界面上雖然可以放按鈕,可以放任何UI控件,但是其不能進行用戶交互,唯一可以進行用戶交互的方式是通過協議中的媒體按鈕及其回調方法。

        定義好了通知UI模板,若要進行使用,還需要再Notification Content擴展中的info.plist文件的NSExtension字典的NSExtensionAttributes字典里進行一些配置,正常情況下,開發者需要進行配置的鍵有3個,分別如下:

UNNotificationExtensionCategory:設置模板的categoryId,用于與UNNotificationContent對應。

UNNotificationExtensionInitialContentSizeRatio:設置自定義通知界面的高度與寬度的比,寬度為固定寬度,在不同設備上有差別,開發者需要根據寬度計算出高度進行設置,系統根據這個比值來計算通知界面的高度。

UNNotificationExtensionDefaultContentHidden:是有隱藏系統默認的通知界面。

配置info.plist文件如下:

用如下的代碼創建通知:

UNNotificationAction * action = [UNNotificationAction actionWithIdentifier:@"action" title:@"活動標題1" options:UNNotificationActionOptionNone];  //根據id拿到自定義UI的模板  UNNotificationCategory * category = [UNNotificationCategory categoryWithIdentifier:@"myNotificationCategoryH" actions:@[action] intentIdentifiers:@[] options:UNNotificationCategoryOptionCustomDismissAction];  UNMutableNotificationContent * content = [UNMutableNotificationContent new];  content.badge = @1;  content.body = @"這是iOS10的新通知內容:普通的iOS通知";  //默認的通知提示音  content.sound = [UNNotificationSound defaultSound];  content.subtitle = @"這里是副標題";  content.title = @"這里是通知的標題";  content.categoryIdentifier = @"myNotificationCategoryH";  //設置5S之后執行  UNTimeIntervalNotificationTrigger * trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:5 repeats:NO];  UNNotificationRequest * request = [UNNotificationRequest requestWithIdentifier:@"NotificationDefaultCustomUIH" content:content trigger:trigger];  [[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:[NSSet setWithObjects:category, nil]];  [[UNUserNotificationCenter currentNotificationCenter] addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {      }];

效果如下圖:

如果將UNNotificationExtensionDefaultContentHidden鍵值設置為0或者不設置,則不會隱藏系統默認的UI,如下:

九、通知回調的處理

        UserNotification框架對于通知的回調處理,是通過UNUserNotificationCenterDelegate協議來實現的,這個協議中有兩個方法,如下:

/*這個方法在應用在前臺,并且將要彈出通知時被調用,后臺狀態下彈通知不會調用這個方法這個方法中的block塊completionHandler()可以傳入一個UNNotificationPresentationOptions類型的枚舉有個這個參數,開發者可以設置在前臺狀態下,依然可以彈出通知消息,枚舉如下:typedef NS_OPTIONS(NSUInteger, UNNotificationPresentationOptions) {  //只修改app圖標的消息數  UNNotificationPresentationOptionBadge  = (1 << 0),  //只提示通知音效  UNNotificationPresentationOptionSound  = (1 << 1),  //只彈出通知框  UNNotificationPresentationOptionAlert  = (1 << 2),} __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);//什么都不做static const UNNotificationPresentationOptions UNNotificationPresentationOptionNone */- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);/*這個方法當接收到通知后,用戶點擊通知激活app時被調用,無論前臺還是后臺*/- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)())completionHandler __IOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0) __TVOS_PROHIBITED;

十、UserNotification框架中其他零散知識

        前面所介紹的內容基本涵蓋了UserNotification框架中所有的內容,在以后的應用開發中,開發者可以在通知方面發揮更大的想象力與創造力,給用戶更加友好的體驗。除了前邊所介紹過的核心內容外,UserNotification框架中還有一些零散的類、枚舉等。

1.錯誤碼描述

typedef NS_ENUM(NSInteger, UNErrorCode) {  //通知不被允許  UNErrorCodeNotificationsNotAllowed = 1,    //附件無效url  UNErrorCodeAttachmentInvalidURL = 100,  //附件類型錯誤  UNErrorCodeAttachmentUnrecognizedType,  //附件大小錯誤  UNErrorCodeAttachmentInvalidFileSize,  //附件數據錯誤  UNErrorCodeAttachmentNotInDataStore,  UNErrorCodeAttachmentMoveIntoDataStoreFailed,  UNErrorCodeAttachmentCorrupt,    //時間無效  UNErrorCodeNotificationInvalidNoDate = 1400,  //無內容  UNErrorCodeNotificationInvalidNoContent,} __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);

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,}

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
中文字幕视频在线免费欧美日韩综合在线看| 78色国产精品| 日韩国产欧美精品一区二区三区| 川上优av一区二区线观看| 欧美视频在线观看免费网址| 美女999久久久精品视频| 久久影院免费观看| 91欧美日韩一区| 久久综合免费视频影院| 欧美自拍大量在线观看| 国产专区精品视频| 久久99青青精品免费观看| 中日韩美女免费视频网站在线观看| 亚洲视频视频在线| 在线观看日韩av| 亚洲欧美第一页| 国产精品mp4| 国产成人亚洲精品| 一区二区国产精品视频| 97av在线视频| 国产精品久久av| 久久久久久伊人| 97视频在线观看视频免费视频| 亚洲视频axxx| 亚洲黄色在线观看| 欧美精品激情在线观看| 欧美日韩美女在线| 欧美国产日韩在线| 日韩美女视频在线观看| 成人性生交大片免费看视频直播| 国内揄拍国内精品少妇国语| 国产精品第一页在线| 色琪琪综合男人的天堂aⅴ视频| 91av视频在线观看| 久久久久久久网站| 日韩成人在线免费观看| 欧美精品做受xxx性少妇| 亚洲国产小视频在线观看| 亚洲无线码在线一区观看| 国产日韩精品电影| 97视频在线观看视频免费视频| 国产精品海角社区在线观看| 久久国产精品久久精品| 久久午夜a级毛片| 亚洲精品欧美极品| 欧美日韩亚洲精品内裤| 7m精品福利视频导航| 成人网欧美在线视频| **欧美日韩vr在线| 国产成人自拍视频在线观看| 欧美大片大片在线播放| 国产综合在线观看视频| 欧美成年人网站| 亚洲mm色国产网站| 久久久91精品国产| 在线看福利67194| 在线丨暗呦小u女国产精品| 成人网在线观看| 国产精品久久久久久久午夜| 草民午夜欧美限制a级福利片| 97在线精品视频| 久久人人爽国产| 日韩av最新在线| 亚洲精品久久久久久下一站| 亚洲日韩欧美视频一区| 亚洲视屏在线播放| 人人澡人人澡人人看欧美| 色综合久久88| 最近免费中文字幕视频2019| 中文字幕亚洲欧美在线| 国产精品高清网站| 日韩电影中文字幕在线观看| 亚洲性视频网站| 91香蕉嫩草影院入口| 精品综合久久久久久97| 欧美极品美女电影一区| 疯狂做受xxxx高潮欧美日本| 欧美精品999| 亚洲国产一区二区三区在线观看| 欧美激情区在线播放| 性视频1819p久久| 精品成人av一区| 亚洲精品视频网上网址在线观看| 亚洲精品日产aⅴ| 国产精品视频精品视频| 欧洲日本亚洲国产区| 蜜臀久久99精品久久久久久宅男| 欧美专区在线播放| 狠狠色狠狠色综合日日小说| 亚洲 日韩 国产第一| 日韩国产精品视频| 欧美在线激情视频| 亚洲精品自在久久| 色琪琪综合男人的天堂aⅴ视频| 91九色国产在线| 日韩欧美大尺度| 亚洲美女www午夜| 91久久嫩草影院一区二区| 久久精品国产91精品亚洲| 国产精品专区h在线观看| 亚洲欧美日韩中文在线制服| 麻豆成人在线看| 欧美亚洲国产精品| 国产精品露脸自拍| 68精品国产免费久久久久久婷婷| 91在线国产电影| 国产午夜精品美女视频明星a级| 亚洲欧洲中文天堂| 亚洲天堂网站在线观看视频| 精品电影在线观看| 国产亚洲一区二区在线| 亚洲国产女人aaa毛片在线| 欧美美女15p| 久久久久久91香蕉国产| 91国偷自产一区二区三区的观看方式| 在线一区二区日韩| 欧美精品午夜视频| 国内精品在线一区| 国产精品男女猛烈高潮激情| 亚洲第一精品自拍| 精品久久久久久中文字幕| 丝袜美腿亚洲一区二区| 欧美放荡办公室videos4k| 色婷婷av一区二区三区在线观看| 成人综合网网址| 欧美视频专区一二在线观看| 国产精品av免费在线观看| 懂色av中文一区二区三区天美| 欧美日韩国产中文字幕| 亚洲国产精品美女| 亚洲色图欧美制服丝袜另类第一页| 亚洲精品一区av在线播放| 国产精品免费久久久久影院| 午夜欧美不卡精品aaaaa| 精品国产依人香蕉在线精品| 日韩精品久久久久久久玫瑰园| 亚洲成色777777女色窝| 欧美成人网在线| 亚洲精品成人免费| 高跟丝袜欧美一区| 午夜精品一区二区三区在线播放| 亚洲成人久久久久| 亚洲片国产一区一级在线观看| 国产亚洲美女久久| 日韩在线视频网站| 97热在线精品视频在线观看| 久久精品国产久精国产思思| 国产精品老女人精品视频| 亚洲iv一区二区三区| 成人444kkkk在线观看| 中文字幕一区二区三区电影| 久久免费福利视频| 日韩精品在线观看视频| 亚洲人成网站免费播放| 欧美噜噜久久久xxx| 欧美国产精品va在线观看| 国产精品美女久久| 自拍偷拍亚洲区| 色狠狠av一区二区三区香蕉蜜桃| 人妖精品videosex性欧美| 久久97精品久久久久久久不卡| 欧美日韩精品二区| 日韩精品中文在线观看| 亚洲jizzjizz日本少妇|