Skip to content

本地通知功能 ​

部分遊戲廠商未實現本地通知功能,可調用該功能相關接口


1. 添加本地通知 ​

函數 ​

objective-c
- (void)gamedreamerAddLocalNotificationWithNotificationObject:(GamedreamerLocalNotification *)notificationObject AndCompletion:(void (^)(NSDictionary *result, NSError *error))completion;

參數 ​

GamedreamerLocalNotification

屬性名屬性類型是否必傳詳細說明
notiIDNSString是本地通知對應的標識ID,如果添加通知的notiID一致,則後添加的通知會覆蓋之前添加的通知,可利用該特性實現同類通知的更新
titleNSString是本地通知的標題
contentNSString是本地通知的內容
isRepeatBOOL是該通知是否為固定週期重複性發送通知
repeatTypeRepeatType否週期性通知重複類型,目前對應三種重複類型:RepeatDaily 每天X時X分進行通知;RepeatWeekly 每週週X X時X分進行通知;RepeatMonthly 每月X日X時X分進行通知
targetTimestampNSString是通知發送時間

示例代碼 ​

objective-c
#import <Gamedreamer/GamedreamerManager.h>

	        GamedreamerLocalNotification *notification = [[GamedreamerLocalNotification alloc] init];
			NSDate *current = NSDate.date;
			notification.notiID = @"123";
			notification.title = @"test title";
			notification.content = @"test content";
			notification.isRepeat = true;
			notification.repeatType = RepeatDaily;
			notification.targetTimestamp = [NSString stringWithFormat:@"%f",[current timeIntervalSince1970]+20];
			[GamedreamerManager.shareInstance gamedreamerAddLocalNotificationWithNotificationObject:notification AndCompletion:^(NSDictionary *result, NSError *error) {
				NSLog(@"--------%@\n%@--------",result, error);
				}];

2. 獲取已添加的本地通知 ​

函數 ​

objective-c
- (void)gamedreamerGetLocalNotificationList:(void (^)(NSArray * notiList))completion;

回調 ​

屬性名屬性類型詳細說明
notiIDNSString本地通知對應的標識ID,如果添加通知的notiID一致,則後添加的通知會覆蓋之前添加的通知,可利用該特性實現同類通知的更新
titleNSString本地通知的標題
contentNSString本地通知的內容
isRepeatBOOL該通知是否為固定週期重複性發送通知
repeatTypeRepeatType週期性通知重複類型,目前對應三種重複類型:RepeatDaily 每天X時X分進行通知;RepeatWeekly 每週週X X時X分進行通知;RepeatMonthly 每月X日X時X分進行通知
targetTimestampNSString通知發送時間

示例代碼 ​

objective-c
[GamedreamerManager.shareInstance gamedreamerGetLocalNotificationList:^(NSArray *notiList) {
            NSLog(@"--------%@--------",notiList);
            for (GamedreamerLocalNotification *item in notiList) {
                NSLog(@"--------%@--------",item.targetTimestamp);
            }
}];

3. 移除已添加的本地通知 ​

函數 ​

objective-c
- (void)gamedreamerRemoveLocalNotificationWithNotiID:(NSString *)notiID;

參數 ​

參數名參數類型參數說明
notiIDNSString刪除目標通知的標識ID

示例代碼 ​

objective-c
[GamedreamerManager.shareInstance gamedreamerRemoveLocalNotificationWithNotiID:@"123"];