本地通知功能
部分遊戲廠商未實現本地通知功能,可調用該功能相關接口
1. 添加本地通知
函數
objective-c
- (void)gamedreamerAddLocalNotificationWithNotificationObject:(GamedreamerLocalNotification *)notificationObject AndCompletion:(void (^)(NSDictionary *result, NSError *error))completion;參數
GamedreamerLocalNotification
| 屬性名 | 屬性類型 | 是否必傳 | 詳細說明 |
|---|---|---|---|
| notiID | NSString | 是 | 本地通知對應的標識ID,如果添加通知的notiID一致,則後添加的通知會覆蓋之前添加的通知,可利用該特性實現同類通知的更新 |
| title | NSString | 是 | 本地通知的標題 |
| content | NSString | 是 | 本地通知的內容 |
| isRepeat | BOOL | 是 | 該通知是否為固定週期重複性發送通知 |
| repeatType | RepeatType | 否 | 週期性通知重複類型,目前對應三種重複類型:RepeatDaily 每天X時X分進行通知;RepeatWeekly 每週週X X時X分進行通知;RepeatMonthly 每月X日X時X分進行通知 |
| targetTimestamp | NSString | 是 | 通知發送時間 |
示例代碼
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;回調
| 屬性名 | 屬性類型 | 詳細說明 |
|---|---|---|
| notiID | NSString | 本地通知對應的標識ID,如果添加通知的notiID一致,則後添加的通知會覆蓋之前添加的通知,可利用該特性實現同類通知的更新 |
| title | NSString | 本地通知的標題 |
| content | NSString | 本地通知的內容 |
| isRepeat | BOOL | 該通知是否為固定週期重複性發送通知 |
| repeatType | RepeatType | 週期性通知重複類型,目前對應三種重複類型:RepeatDaily 每天X時X分進行通知;RepeatWeekly 每週週X X時X分進行通知;RepeatMonthly 每月X日X時X分進行通知 |
| targetTimestamp | NSString | 通知發送時間 |
示例代碼
objective-c
[GamedreamerManager.shareInstance gamedreamerGetLocalNotificationList:^(NSArray *notiList) {
NSLog(@"--------%@--------",notiList);
for (GamedreamerLocalNotification *item in notiList) {
NSLog(@"--------%@--------",item.targetTimestamp);
}
}];3. 移除已添加的本地通知
函數
objective-c
- (void)gamedreamerRemoveLocalNotificationWithNotiID:(NSString *)notiID;參數
| 參數名 | 參數類型 | 參數說明 |
|---|---|---|
| notiID | NSString | 刪除目標通知的標識ID |
示例代碼
objective-c
[GamedreamerManager.shareInstance gamedreamerRemoveLocalNotificationWithNotiID:@"123"];