Local notification function
Some game manufacturers do not implement the local notification function, and can call the relevant interface of this function.
1. Add local notifications
Function
objective-c
- (void)gamedreamerAddLocalNotificationWithNotificationObject:(GamedreamerLocalNotification *)notificationObject AndCompletion:(void (^)(NSDictionary *result, NSError *error))completion;Parameter
GamedreamerLocalNotification
| Attribute Name | Attribute Type | Required or not | detailed description |
|---|---|---|---|
| notiID | NSString | Yes | The ID corresponding to the local notification. If the notiID of the added notification is the same, the added notification overwrites the previously added notification. This feature can be used to update similar notifications. |
| title | NSString | Yes | Title of the local notification |
| content | NSString | Yes | Contents of local notifications |
| isRepeat | BOOL | Yes | Whether the notification is a fixed-cycle repetitive sending notification |
| repeatType | RepeatType | No | Periodic notification repetition type, currently corresponding to three repetition types: repeatDaily notification at X hours and X minutes per day; repeatWeekly notification at X hours and X minutes per week; repeatMonthly notification at X hours and X minutes per month |
| targetTimestamp | NSString | Yes | Notification sending time |
Example code
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. Get added local notifications.
Function
objective-c
- (void)gamedreamerGetLocalNotificationList:(void (^)(NSArray * notiList))completion;Callback
| Attribute Name | Attribute Type | detailed description |
|---|---|---|
| notiID | NSString | The ID corresponding to the local notification. If the notiID of the added notification is the same, the added notification overwrites the previously added notification. This feature can be used to update similar notifications. |
| title | NSString | Title of the local notification |
| content | NSString | Contents of local notifications |
| isRepeat | BOOL | Whether the notification is a fixed-cycle repetitive sending notification |
| repeatType | RepeatType | Periodic notification repetition type, currently corresponding to three repetition types: repeatDaily notification at X hours and X minutes per day; repeatWeekly notification at X hours and X minutes per week; repeatMonthly notification at X hours and X minutes per month |
| targetTimestamp | NSString | Notification sending time |
Example code
objective-c
[GamedreamerManager.shareInstance gamedreamerGetLocalNotificationList:^(NSArray *notiList) {
NSLog(@"--------%@--------",notiList);
for (GamedreamerLocalNotification *item in notiList) {
NSLog(@"--------%@--------",item.targetTimestamp);
}
}];3. Remove the added local notification
Function
objective-c
- (Void)gamedreamerRemoveLocalNotificationWithNotiID:(NSString *)notiID;Parameter
| Parameter name | Parameter type | parameter specification |
|---|---|---|
| notiID | NSString | ID of the target notification. |
Example code
objective-c
[GamedreamerManager.shareInstance gamedreamerRemoveLocalNotificationWithNotiID:@"123"];