Skip to content

Commit f6fba6e

Browse files
committed
ios 开放本地通知定时展示字段
1 parent 16d4ab9 commit f6fba6e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

ios/RCTJPushModule/RCTJPushModule.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#define EXTRAS @"extras"
1717
#define BADGE @"badge"
1818
#define RING @"ring"
19+
#definr BROADCASTTIME @"broadcastTime"
1920

2021
//本地角标
2122
#define APP_BADGE @"appBadge"
@@ -412,14 +413,23 @@ - (void)sendPropertiesEvent:(NSDictionary *)data
412413
NSString *notificationContent = params[CONTENT]?params[CONTENT]:@"";
413414
content.title = notificationTitle;
414415
content.body = notificationContent;
416+
if (@available(iOS 15.0, *)) {
417+
content.interruptionLevel = 1;
418+
} else {
419+
// Fallback on earlier versions
420+
}
415421
if(params[EXTRAS]){
416422
content.userInfo = @{MESSAGE_ID:messageID,TITLE:notificationTitle,CONTENT:notificationContent,EXTRAS:params[EXTRAS]};
417423
}else{
418424
content.userInfo = @{MESSAGE_ID:messageID,TITLE:notificationTitle,CONTENT:notificationContent};
419425
}
426+
NSString *broadcastTime = params[BROADCASTTIME];
420427
JPushNotificationTrigger *trigger = [[JPushNotificationTrigger alloc] init];
421428
NSDateComponents *components = [[NSDateComponents alloc] init];
422429
NSDate *now = [NSDate date];
430+
if (broadcastTime && [broadcastTime isKindOfClass:[NSString class]]) {
431+
now = [NSDate dateWithTimeIntervalSince1970:[broadcastTime integerValue]/1000];
432+
}
423433
NSCalendar *calendar = [NSCalendar currentCalendar];
424434
NSUInteger unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
425435
NSDateComponents *dateComponent = [calendar components:unitFlags fromDate:now];

0 commit comments

Comments
 (0)