Skip to content

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 NameAttribute TypeRequired or notdetailed description
notiIDNSStringYesThe 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.
titleNSStringYesTitle of the local notification
contentNSStringYesContents of local notifications
isRepeatBOOLYesWhether the notification is a fixed-cycle repetitive sending notification
repeatTypeRepeatTypeNoPeriodic 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
targetTimestampNSStringYesNotification 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 NameAttribute Typedetailed description
notiIDNSStringThe 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.
titleNSStringTitle of the local notification
contentNSStringContents of local notifications
isRepeatBOOLWhether the notification is a fixed-cycle repetitive sending notification
repeatTypeRepeatTypePeriodic 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
targetTimestampNSStringNotification 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 nameParameter typeparameter specification
notiIDNSStringID of the target notification.

Example code ​

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