NativeBridge.m 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. //
  2. // NativeBridge.m
  3. // hola
  4. //
  5. // Created by Leon on 2024/4/28.
  6. //
  7. #import <Foundation/Foundation.h>
  8. #import "NativeBridge.h"
  9. #import "AppDelegate.h"
  10. #import <CoreLocation/CoreLocation.h>
  11. @interface NativeBridge()
  12. @end
  13. @implementation NativeBridge
  14. @synthesize bridge = _bridge;
  15. RCT_EXPORT_MODULE()
  16. - (instancetype)init {
  17. self = [super init];
  18. if (self) {
  19. AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  20. appDelegate.nativeBridge = self;
  21. // 在这里进行初始化操作
  22. }
  23. return self;
  24. }
  25. -(NSArray<NSString *>*)supportedEvents
  26. {
  27. return @[@"receive"];
  28. //EventReminder 是监听的标识,类似 iOS 发通知 需要一个标识去识别,通过这个标识发送通知调用 RN方法
  29. }
  30. RCT_EXPORT_METHOD(rnPageLoaded){
  31. dispatch_async(dispatch_get_main_queue(), ^{
  32. AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  33. appDelegate.rnLoaded = YES;
  34. });
  35. }
  36. RCT_EXPORT_METHOD(getLocationAuthStatus:(RCTResponseSenderBlock)callback){
  37. dispatch_async(dispatch_get_main_queue(), ^{
  38. BOOL isLocation = [CLLocationManager locationServicesEnabled];
  39. CLAuthorizationStatus status = [CLLocationManager authorizationStatus];
  40. switch (status) {
  41. case kCLAuthorizationStatusNotDetermined:
  42. callback(@[
  43. @{
  44. @"location_services_enabled":isLocation?@"true":@"false",
  45. @"authorization_status":@"not_determined"
  46. }
  47. ]);
  48. break;
  49. case kCLAuthorizationStatusDenied:
  50. callback(@[
  51. @{
  52. @"location_services_enabled":isLocation?@"true":@"false",
  53. @"authorization_status":@"denied"
  54. }
  55. ]);
  56. break;
  57. case kCLAuthorizationStatusAuthorizedAlways:
  58. callback(@[
  59. @{
  60. @"location_services_enabled":isLocation?@"true":@"false",
  61. @"authorization_status":@"always"
  62. }
  63. ]);
  64. break;
  65. case kCLAuthorizationStatusAuthorizedWhenInUse:
  66. callback(@[
  67. @{
  68. @"location_services_enabled":isLocation?@"true":@"false",
  69. @"authorization_status":@"when_in_use"
  70. }
  71. ]);
  72. break;
  73. default:
  74. callback(@[
  75. @{
  76. @"location_services_enabled":isLocation?@"true":@"false",
  77. @"authorization_status":@"other"
  78. }
  79. ]);
  80. break;
  81. }
  82. });
  83. }
  84. RCT_EXPORT_METHOD(getNotificationAuthStatus){
  85. dispatch_async(dispatch_get_main_queue(), ^{
  86. UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
  87. [center getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
  88. UNAuthorizationStatus status = settings.authorizationStatus;
  89. switch (status) {
  90. case UNAuthorizationStatusAuthorized:
  91. NSLog(@"用户已授权通知权限");
  92. [self.bridge.eventDispatcher sendAppEventWithName:@"notificationResult" body:@"authorized"];
  93. break;
  94. case UNAuthorizationStatusDenied:
  95. NSLog(@"用户已拒绝通知权限");
  96. [self.bridge.eventDispatcher sendAppEventWithName:@"notificationResult" body:@"denied"];
  97. break;
  98. case UNAuthorizationStatusNotDetermined:
  99. NSLog(@"通知权限未确定");
  100. [self.bridge.eventDispatcher sendAppEventWithName:@"notificationResult" body:@"not_determined"];
  101. break;
  102. default:
  103. break;
  104. }
  105. }];
  106. });
  107. }
  108. RCT_EXPORT_METHOD(authNotification){
  109. dispatch_async(dispatch_get_main_queue(), ^{
  110. UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
  111. [center requestAuthorizationWithOptions:(UNAuthorizationOptionAlert | UNAuthorizationOptionSound | UNAuthorizationOptionBadge|UNAuthorizationOptionProvidesAppNotificationSettings) completionHandler:^(BOOL granted, NSError * _Nullable error) {
  112. if (granted) {
  113. [self.bridge.eventDispatcher sendAppEventWithName:@"operateNotificationResult" body:@"authorized"];
  114. dispatch_async(dispatch_get_main_queue(), ^{
  115. [[UIApplication sharedApplication] registerForRemoteNotifications];
  116. });
  117. } else {
  118. // 用户拒绝通知或发生错误
  119. [self.bridge.eventDispatcher sendAppEventWithName:@"operateNotificationResult" body:@"denied"];
  120. }
  121. }];
  122. });
  123. }
  124. RCT_EXPORT_METHOD(clearNotification){
  125. dispatch_async(dispatch_get_main_queue(), ^{
  126. UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
  127. [center removeAllPendingNotificationRequests];
  128. });
  129. }
  130. RCT_EXPORT_METHOD(addSunPushzzz:(id)array){
  131. dispatch_async(dispatch_get_main_queue(), ^{
  132. UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
  133. // [center removeAllPendingNotificationRequests];
  134. [center getPendingNotificationRequestsWithCompletionHandler:^(NSArray<UNNotificationRequest *> * _Nonnull requests) {
  135. NSLog(@"%d",requests.count);
  136. }];
  137. // [center removeAllPendingNotificationRequests];
  138. [center removePendingNotificationRequestsWithIdentifiers:@[
  139. @"REMINDER_SUN_RISE",
  140. @"REMINDER_SUN_SET",
  141. @"REMINDER_SUN_SOLAR_NOON"
  142. ]];
  143. });
  144. }
  145. RCT_EXPORT_METHOD(addSunPush:(id)array){
  146. dispatch_async(dispatch_get_main_queue(), ^{
  147. UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
  148. // [center removeAllPendingNotificationRequests];
  149. [center getPendingNotificationRequestsWithCompletionHandler:^(NSArray<UNNotificationRequest *> * _Nonnull requests) {
  150. NSLog(@"%d",requests.count);
  151. }];
  152. // [center removeAllPendingNotificationRequests];
  153. [center removePendingNotificationRequestsWithIdentifiers:@[
  154. @"REMINDER_SUN_RISE",
  155. @"REMINDER_SUN_SET",
  156. @"REMINDER_SUN_SOLAR_NOON"
  157. ]];
  158. NSMutableArray *ids = [NSMutableArray new];
  159. for (int i =0;i<[array count];i++){
  160. id detail = array[i];
  161. [ids addObject:[NSString stringWithFormat:@"%@",detail[@"timestamp"]]];
  162. }
  163. [center removePendingNotificationRequestsWithIdentifiers:ids];
  164. NSMutableArray *list = [NSMutableArray new];
  165. NSUInteger count = [array count];
  166. if (count>30){
  167. count = 30;
  168. }
  169. for (int i=0;i<count;i++){
  170. id detail = array[i];
  171. NSTimeInterval timestamp = [detail[@"timestamp"] doubleValue]/1000; // 毫秒级时间戳
  172. // 获取当前时间
  173. NSDate *currentDate = [NSDate date];
  174. // 计算当前时间与给定时间戳之间的时间差(秒)
  175. NSTimeInterval timeInterval = timestamp - [currentDate timeIntervalSince1970];
  176. if (timeInterval<0){
  177. continue;
  178. }
  179. NSString * identifier = detail[@"category_id"];
  180. UNMutableNotificationContent * content = [[UNMutableNotificationContent alloc] init];
  181. content.title = detail[@"title"];
  182. content.body = detail[@"body"];
  183. content.sound = [UNNotificationSound defaultSound];
  184. content.badge = @([UIApplication sharedApplication].applicationIconBadgeNumber + 1);
  185. UNNotificationCategory *categroy = [UNNotificationCategory categoryWithIdentifier:[NSString stringWithFormat:@"%@",detail[@"timestamp"]] actions:@[] intentIdentifiers:@[] options:UNNotificationCategoryOptionCustomDismissAction];
  186. [list addObject:categroy];
  187. // [[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:[NSSet setWithObject:categroy]];
  188. content.categoryIdentifier = [NSString stringWithFormat:@"%@",detail[@"timestamp"]];
  189. UNTimeIntervalNotificationTrigger * trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:timeInterval repeats:NO];
  190. UNNotificationRequest * request = [UNNotificationRequest requestWithIdentifier:[NSString stringWithFormat:@"%@",detail[@"timestamp"]] content:content trigger:trigger];
  191. [[UNUserNotificationCenter currentNotificationCenter] addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {
  192. }];
  193. }
  194. [[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:[NSSet setWithArray:list]];
  195. // for (int i=0;i<7;i++){
  196. // id detail = array[i];
  197. // UNMutableNotificationContent * content = [[UNMutableNotificationContent alloc] init];
  198. // content.title = detail[@"title"];
  199. // content.body = detail[@"body"];
  200. // content.sound = [UNNotificationSound defaultSound];
  201. // content.badge = @([UIApplication sharedApplication].applicationIconBadgeNumber + 1);
  202. //
  203. // NSString *category_id = detail[@"category_id"];
  204. //
  205. // NSTimeInterval timestamp = [detail[@"timestamp"] doubleValue]/1000; // 毫秒级时间戳
  206. // // 获取当前时间
  207. // NSDate *currentDate = [NSDate date];
  208. // // 计算当前时间与给定时间戳之间的时间差(秒)
  209. // NSTimeInterval timeInterval = timestamp - [currentDate timeIntervalSince1970];
  210. //
  211. // if (timeInterval<0){
  212. // continue;
  213. // }
  214. //
  215. // UNNotificationCategory *categroy = [UNNotificationCategory categoryWithIdentifier:category_id actions:@[
  216. // [UNNotificationAction actionWithIdentifier:@"LOG_MY_TIMES" title:@"Log my times" options:UNNotificationActionOptionForeground]
  217. // ] intentIdentifiers:@[] options:UNNotificationCategoryOptionCustomDismissAction];
  218. // [list addObject:categroy];
  219. // // [[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:[NSSet setWithObject:categroy]];
  220. // content.categoryIdentifier = category_id;
  221. //
  222. // UNTimeIntervalNotificationTrigger * trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:timeInterval repeats:NO];
  223. // NSString * identifier = detail[@"category_id"];
  224. // UNNotificationRequest * request = [UNNotificationRequest requestWithIdentifier:identifier content:content trigger:trigger];
  225. // [[UNUserNotificationCenter currentNotificationCenter] addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {
  226. //
  227. // }];
  228. //
  229. //
  230. // }
  231. // [[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:[NSSet setWithArray:list]];
  232. });
  233. }
  234. RCT_EXPORT_METHOD(addLocalPush:(id)array){
  235. dispatch_async(dispatch_get_main_queue(), ^{
  236. UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
  237. // [center removeAllPendingNotificationRequests];
  238. [center removePendingNotificationRequestsWithIdentifiers:@[
  239. @"REMINDER_FS_START_FAST",
  240. @"REMINDER_FS_START_SLEEP",
  241. @"REMINDER_FS_END_FAST",
  242. @"REMINDER_FS_END_SLEEP",
  243. @"REMINDER_FS_START_FAST_T2",
  244. @"REMINDER_FS_START_FAST_T3",
  245. @"REMINDER_FS_START_FAST_T4",
  246. @"REMINDER_FS_START_SLEEP_T3",
  247. @"REMINDER_FS_START_SLEEP_T4",
  248. @"REMINDER_FS_END_SLEEP_T4"
  249. ]];
  250. NSMutableArray *list = [NSMutableArray new];
  251. for (int i=0;i<[array count];i++){
  252. id detail = array[i];
  253. NSString *mode = detail[@"mode"];
  254. if (![mode isEqualToString:@"RECURRING"]){
  255. NSTimeInterval timestamp = [detail[@"once"] doubleValue]/1000; // 毫秒级时间戳
  256. // 获取当前时间
  257. NSDate *currentDate = [NSDate date];
  258. // 计算当前时间与给定时间戳之间的时间差(秒)
  259. NSTimeInterval timeInterval = timestamp - [currentDate timeIntervalSince1970];
  260. if (timeInterval<0){
  261. continue;
  262. }
  263. }
  264. //设置通知内容
  265. UNMutableNotificationContent * content = [[UNMutableNotificationContent alloc] init];
  266. content.title = detail[@"title"];
  267. content.body = [NSString stringWithFormat:@"%@\nPress for actions >>",detail[@"body"]];
  268. content.sound = [UNNotificationSound defaultSound];
  269. content.badge = @([UIApplication sharedApplication].applicationIconBadgeNumber + 1);
  270. if (@available(iOS 15.0,*)){
  271. content.interruptionLevel = UNNotificationInterruptionLevelActive;
  272. }
  273. NSString *category_id = detail[@"category_id"];
  274. NSString *message_id = detail[@"id"];
  275. NSArray *actions;
  276. if ([category_id isEqualToString:@"REMINDER_FS_START_FAST"]||[category_id isEqualToString:@"REMINDER_FS_START_SLEEP"]){
  277. //消息的处理按钮
  278. UNNotificationAction *action1 = [UNNotificationAction actionWithIdentifier:@"START_TIMER_NOW" title:@"Start timer now with 1-tap" options:UNNotificationActionOptionForeground];
  279. UNNotificationAction *action2 = [UNNotificationAction actionWithIdentifier:@"PICK_EARLIER_START" title:@"Pick an earlier start" options:UNNotificationActionOptionForeground];
  280. UNNotificationAction *action3 = [UNNotificationAction actionWithIdentifier:@"SKIP" title:@"Skip" options:UNNotificationActionOptionAuthenticationRequired];
  281. actions = @[action1,action2,action3];
  282. }
  283. else if([category_id isEqualToString:@"REMINDER_FS_END_FAST"]||[category_id isEqualToString:@"REMINDER_FS_END_SLEEP"]){
  284. //消息的处理按钮
  285. UNNotificationAction *action1 = [UNNotificationAction actionWithIdentifier:@"END_TIMER_NOW" title:@"End timer now with 1-tap" options:UNNotificationActionOptionForeground];
  286. UNNotificationAction *action2 = [UNNotificationAction actionWithIdentifier:@"PICK_EARLIER_END" title:@"Pick an earlier end" options:UNNotificationActionOptionForeground];
  287. UNNotificationAction *action3 = [UNNotificationAction actionWithIdentifier:@"SKIP" title:@"Skip" options:UNNotificationActionOptionAuthenticationRequired];
  288. actions = @[action1,action2,action3];
  289. }
  290. else if ([category_id isEqualToString:@"REMINDER_FS_START_FAST_T2"]||
  291. [category_id isEqualToString:@"REMINDER_FS_START_FAST_T3"]||
  292. [category_id isEqualToString:@"REMINDER_FS_START_FAST_T4"]||
  293. [category_id isEqualToString:@"REMINDER_FS_START_SLEEP_T3"]||
  294. [category_id isEqualToString:@"REMINDER_FS_START_SLEEP_T4"]||
  295. [category_id isEqualToString:@"REMINDER_FS_END_SLEEP_T4"]){
  296. UNNotificationAction *action2 = [UNNotificationAction actionWithIdentifier:@"LOG_MY_TIMES" title:@"Log my times" options:UNNotificationActionOptionForeground];
  297. UNNotificationAction *action3 = [UNNotificationAction actionWithIdentifier:@"SKIP" title:@"Skip" options:UNNotificationActionOptionAuthenticationRequired];
  298. actions = @[action2,action3];
  299. }
  300. UNNotificationCategory *categroy = [UNNotificationCategory categoryWithIdentifier:category_id actions:actions intentIdentifiers:@[] options:UNNotificationCategoryOptionCustomDismissAction];
  301. [list addObject:categroy];
  302. // [[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:[NSSet setWithObject:categroy]];
  303. content.categoryIdentifier = category_id;
  304. if ([mode isEqualToString:@"RECURRING"]){
  305. //设置推送的触发机制
  306. NSArray *timeArray = [detail[@"recurring"][@"time"] componentsSeparatedByString:@":"];
  307. NSInteger hour = [[timeArray objectAtIndex:0] integerValue];
  308. NSInteger minute = [[timeArray objectAtIndex:1] integerValue];
  309. NSInteger second = [[timeArray objectAtIndex:2] integerValue];
  310. // 2. 设置触发条件
  311. NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
  312. dateComponents.hour = hour;
  313. dateComponents.minute = minute;
  314. dateComponents.second = second;
  315. UNCalendarNotificationTrigger *trigger = [UNCalendarNotificationTrigger triggerWithDateMatchingComponents:dateComponents repeats:YES];
  316. NSString * identifier = message_id;
  317. UNNotificationRequest * request = [UNNotificationRequest requestWithIdentifier:identifier content:content trigger:trigger];
  318. [[UNUserNotificationCenter currentNotificationCenter] addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {
  319. }];
  320. }
  321. else {
  322. NSTimeInterval timestamp = [detail[@"once"] doubleValue]/1000; // 毫秒级时间戳
  323. // 获取当前时间
  324. NSDate *currentDate = [NSDate date];
  325. // 计算当前时间与给定时间戳之间的时间差(秒)
  326. NSTimeInterval timeInterval = timestamp - [currentDate timeIntervalSince1970];
  327. UNTimeIntervalNotificationTrigger * trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:timeInterval repeats:NO];
  328. NSString * identifier = message_id;
  329. UNNotificationRequest * request = [UNNotificationRequest requestWithIdentifier:identifier content:content trigger:trigger];
  330. [[UNUserNotificationCenter currentNotificationCenter] addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {
  331. }];
  332. }
  333. }
  334. [[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:[NSSet setWithArray:list]];
  335. });
  336. }
  337. RCT_EXPORT_METHOD(addLocalPush3:(id)detail){
  338. dispatch_async(dispatch_get_main_queue(), ^{
  339. //设置通知内容
  340. UNMutableNotificationContent * content = [[UNMutableNotificationContent alloc] init];
  341. content.title = detail[@"title"];
  342. content.body = detail[@"body"];
  343. NSString *category_id = detail[@"category_id"];
  344. NSString *message_id = detail[@"id"];
  345. NSString *mode = detail[@"mode"];
  346. NSArray *actions;
  347. if ([category_id isEqualToString:@"REMINDER_FS_START_FAST"]||[category_id isEqualToString:@"REMINDER_FS_START_SLEEP"]){
  348. //消息的处理按钮
  349. UNNotificationAction *action1 = [UNNotificationAction actionWithIdentifier:@"START_TIMER_NOW" title:@"Start timer now with 1-tap" options:UNNotificationActionOptionForeground];
  350. UNNotificationAction *action2 = [UNNotificationAction actionWithIdentifier:@"PICK_EARLIER_START" title:@"Pick an earlier start" options:UNNotificationActionOptionForeground];
  351. UNNotificationAction *action3 = [UNNotificationAction actionWithIdentifier:@"SKIP" title:@"Skip" options:UNNotificationActionOptionAuthenticationRequired];
  352. actions = @[action1,action2,action3];
  353. }
  354. else if([category_id isEqualToString:@"REMINDER_FS_END_FAST"]||[category_id isEqualToString:@"REMINDER_FS_END_SLEEP"]){
  355. //消息的处理按钮
  356. UNNotificationAction *action1 = [UNNotificationAction actionWithIdentifier:@"END_TIMER_NOW" title:@"End timer now with 1-tap" options:UNNotificationActionOptionForeground];
  357. UNNotificationAction *action2 = [UNNotificationAction actionWithIdentifier:@"PICK_EARLIER_END" title:@"Pick an earlier end" options:UNNotificationActionOptionForeground];
  358. UNNotificationAction *action3 = [UNNotificationAction actionWithIdentifier:@"SKIP" title:@"Skip" options:UNNotificationActionOptionAuthenticationRequired];
  359. actions = @[action1,action2,action3];
  360. }
  361. UNNotificationCategory *categroy = [UNNotificationCategory categoryWithIdentifier:category_id actions:actions intentIdentifiers:@[] options:UNNotificationCategoryOptionCustomDismissAction];
  362. [[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:[NSSet setWithObject:categroy]];
  363. content.categoryIdentifier = category_id;
  364. if ([mode isEqualToString:@"RECURRING"]){
  365. //设置推送的触发机制
  366. NSArray *timeArray = [detail[@"recurring"][@"time"] componentsSeparatedByString:@":"];
  367. NSInteger hour = [[timeArray objectAtIndex:0] integerValue];
  368. NSInteger minute = [[timeArray objectAtIndex:1] integerValue];
  369. NSInteger second = [[timeArray objectAtIndex:2] integerValue];
  370. // 2. 设置触发条件
  371. NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
  372. dateComponents.hour = hour;
  373. dateComponents.minute = minute;
  374. dateComponents.second = second;
  375. UNCalendarNotificationTrigger *trigger = [UNCalendarNotificationTrigger triggerWithDateMatchingComponents:dateComponents repeats:YES];
  376. NSString * identifier = message_id;
  377. UNNotificationRequest * request = [UNNotificationRequest requestWithIdentifier:identifier content:content trigger:trigger];
  378. [[UNUserNotificationCenter currentNotificationCenter] addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {
  379. }];
  380. }
  381. else {
  382. NSTimeInterval timestamp = [detail[@"once"] doubleValue]/1000; // 毫秒级时间戳
  383. // 获取当前时间
  384. NSDate *currentDate = [NSDate date];
  385. // 计算当前时间与给定时间戳之间的时间差(秒)
  386. NSTimeInterval timeInterval = timestamp - [currentDate timeIntervalSince1970];
  387. UNTimeIntervalNotificationTrigger * trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:timeInterval repeats:NO];
  388. NSString * identifier = message_id;
  389. UNNotificationRequest * request = [UNNotificationRequest requestWithIdentifier:identifier content:content trigger:trigger];
  390. [[UNUserNotificationCenter currentNotificationCenter] addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {
  391. }];
  392. }
  393. });
  394. }
  395. @end