Leon hai 1 ano
pai
achega
b67e2da081

+ 1 - 1
ios/AppDelegate.mm

@@ -142,7 +142,7 @@ static NSString *const kRNConcurrentRoot = @"concurrentRoot";
 - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
 {
 //  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
-#if DEBUG
+#if DEBUGAAA
   return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
 #else
   return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];

+ 57 - 116
ios/NativeBridge.m

@@ -91,6 +91,62 @@ RCT_EXPORT_METHOD(authNotification){
   });
 }
 
+RCT_EXPORT_METHOD(addLocalPush2:(id)detail){
+  dispatch_async(dispatch_get_main_queue(), ^{
+    //设置通知内容
+    UNMutableNotificationContent * content = [[UNMutableNotificationContent alloc] init];
+    content.title = @"a1";
+    content.body = @"b1";
+    
+    UNNotificationAction *action1 = [UNNotificationAction actionWithIdentifier:@"START_TIMER_NOW1" title:@"Start timer now with 1-tap" options:UNNotificationActionOptionForeground];
+    
+    UNNotificationAction *action2 = [UNNotificationAction actionWithIdentifier:@"PICK_EARLIER_START2" title:@"Pick an earlier start" options:UNNotificationActionOptionForeground];
+    NSArray *actions = @[action1,action2];
+    
+    
+    UNNotificationCategory *categroy = [UNNotificationCategory categoryWithIdentifier:@"c1" actions:actions intentIdentifiers:@[] options:UNNotificationCategoryOptionCustomDismissAction];
+    
+    [[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:[NSSet setWithObject:categroy]];
+    content.categoryIdentifier = @"c1";
+    
+    UNTimeIntervalNotificationTrigger * trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:10 repeats:NO];
+    NSString * identifier = @"e1";
+    UNNotificationRequest * request = [UNNotificationRequest requestWithIdentifier:identifier content:content trigger:trigger];
+    [[UNUserNotificationCenter currentNotificationCenter] addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {
+      
+    }];
+    
+    UNMutableNotificationContent * content2 = [[UNMutableNotificationContent alloc] init];
+    content2.title = @"a12";
+    content2.body = @"b12";
+    
+    NSArray *actions2;
+    
+    UNNotificationAction *action12 = [UNNotificationAction actionWithIdentifier:@"START_TIMER_NOW" title:@"Start timer now with 1-tap" options:UNNotificationActionOptionForeground];
+    
+    UNNotificationAction *action22 = [UNNotificationAction actionWithIdentifier:@"PICK_EARLIER_START" title:@"Pick an earlier start" options:UNNotificationActionOptionForeground];
+    
+    UNNotificationAction *action32 = [UNNotificationAction actionWithIdentifier:@"SKIP" title:@"Skip" options:UNNotificationActionOptionAuthenticationRequired];
+    actions2 = @[action12,action22,action32];
+    
+    
+    UNNotificationCategory *categroy2 = [UNNotificationCategory categoryWithIdentifier:@"c12" actions:actions2 intentIdentifiers:@[] options:UNNotificationCategoryOptionCustomDismissAction];
+    
+    [[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:[NSSet setWithObject:categroy2]];
+    content2.categoryIdentifier = @"c12";
+
+    UNTimeIntervalNotificationTrigger * trigger2 = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:15 repeats:NO];
+    NSString * identifier2 = @"e12";
+    UNNotificationRequest * request2 = [UNNotificationRequest requestWithIdentifier:identifier2 content:content2 trigger:trigger2];
+    [[UNUserNotificationCenter currentNotificationCenter] addNotificationRequest:request2 withCompletionHandler:^(NSError * _Nullable error) {
+      
+    }];
+    
+    
+  });
+}
+
+
 RCT_EXPORT_METHOD(addLocalPush:(id)detail){
   dispatch_async(dispatch_get_main_queue(), ^{
     //设置通知内容
@@ -119,13 +175,11 @@ RCT_EXPORT_METHOD(addLocalPush:(id)detail){
       
       UNNotificationAction *action2 = [UNNotificationAction actionWithIdentifier:@"PICK_EARLIER_END" title:@"Pick an earlier end" options:UNNotificationActionOptionForeground];
       
-      UNNotificationAction *action3 = [UNNotificationAction actionWithIdentifier:@"Skip" title:@"SKIP" options:UNNotificationActionOptionAuthenticationRequired];
+      UNNotificationAction *action3 = [UNNotificationAction actionWithIdentifier:@"SKIP" title:@"Skip" options:UNNotificationActionOptionAuthenticationRequired];
       
       actions = @[action1,action2,action3];
     }
     
-    
-    
     UNNotificationCategory *categroy = [UNNotificationCategory categoryWithIdentifier:category_id actions:actions intentIdentifiers:@[] options:UNNotificationCategoryOptionCustomDismissAction];
     
     [[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:[NSSet setWithObject:categroy]];
@@ -171,119 +225,6 @@ RCT_EXPORT_METHOD(addLocalPush:(id)detail){
   });
 }
 
-
-//RCT_EXPORT_METHOD(addLocalPush:(NSString *)title
-//                  withBody:(NSString *)body
-//                  withTime:(NSString *)time
-//                  withDetail:(id)detail){
-//  dispatch_async(dispatch_get_main_queue(), ^{
-//    //设置通知内容
-//    UNMutableNotificationContent * content = [[UNMutableNotificationContent alloc] init];
-//    content.title = title;
-//    content.body = body;
-//    //        content.subtitle = @"推送的子标题";
-//    //        content.badge = [NSNumber numberWithInteger:0];// 红标
-//    //        content.sound = [UNNotificationSound defaultSound];
-//    //[UNNotificationSound soundNamed:@""]; 自定义推送声音
-//
-//    //        //给通知添加本地图片或者视频,写法同下
-//    //        NSString *path = [[NSBundle mainBundle] pathForResource:@"rank2" ofType:@"png"];
-//    //        NSError *error = nil;
-//    //        /*
-//    //         UNNotificationAttachment是指可以包含音频,图像或视频内容。使用本地通知时,可以在通知创建时,将附件加入即可。对于远程通知,则必须实现使用UNNotificationServiceExtension类通知服务扩展。
-//    //         */
-//    //        UNNotificationAttachment *img_attachment = [UNNotificationAttachment attachmentWithIdentifier:@"att1" URL:[NSURL fileURLWithPath:path] options:nil error:&error];
-//    //        if (error) {
-//    //            NSLog(@"%@", error);
-//    //        }
-//    //        content.attachments = @[img_attachment];//默认只显示第一个
-//    //        content.launchImageName = @"launch2";
-//
-//    //消息的处理按钮
-//    UNNotificationAction *action1 = [UNNotificationAction actionWithIdentifier:@"START_TIMER_NOW" title:@"START_TIMER_NOW" options:UNNotificationActionOptionForeground];
-//
-//    UNNotificationAction *action2 = [UNNotificationAction actionWithIdentifier:@"PICK_EARLIER_START" title:@"PICK_EARLIER_START" options:UNNotificationActionOptionForeground];
-//
-//    UNNotificationAction *action3 = [UNNotificationAction actionWithIdentifier:@"SKIP" title:@"SKIP" options:UNNotificationActionOptionAuthenticationRequired];
-//
-//    UNNotificationCategory *categroy = [UNNotificationCategory categoryWithIdentifier:@"REMINDER_FS_START_FAST" actions:@[action1,action2,action3] intentIdentifiers:@[] options:UNNotificationCategoryOptionCustomDismissAction];
-//
-//    [[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:[NSSet setWithObject:categroy]];
-//    content.categoryIdentifier = @"REMINDER_FS_START_FAST";
-//
-//    //设置推送的触发机制
-//    UNTimeIntervalNotificationTrigger * trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:10 repeats:NO];
-//
-//    //日历形式,
-//    //    NSDateComponents * dateComp = [[NSDateComponents alloc] init];
-//    //    dateComp.weekday = 2;//周一,默认第一天是周日
-//    //    dateComp.month = 12;//月份,您可以在这里设置具体的时分秒
-//    //    dateComp.hour = 10;//小时
-//    //    dateComp.minute = 14;//分钟
-//    //    UNCalendarNotificationTrigger * calendarTrigger = [UNCalendarNotificationTrigger triggerWithDateMatchingComponents:dateComp repeats:YES];
-//
-//    //地理位置推送.没实际应用过
-//    //    CLLocationCoordinate2D  location ;
-//    //    location.latitude = 123;
-//    //    location.longitude = 111;
-//    //
-//    //    CLCircularRegion * region = [[CLCircularRegion alloc] initWithCenter:location radius:100.0 identifier:@"regionid"];
-//    //
-//    //    UNLocationNotificationTrigger * locationTrigger = [UNLocationNotificationTrigger triggerWithRegion:region repeats:YES];
-//
-//    NSString * identifier = @"notification_onlytextid";
-//    UNNotificationRequest * request = [UNNotificationRequest requestWithIdentifier:identifier content:content trigger:trigger];
-//    [[UNUserNotificationCenter currentNotificationCenter] addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {
-//
-//    }];
-//
-//    //    // 1. 设置 notification 内容
-//    //    UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init];
-//    //    content.title = title;
-//    //    content.body = body;
-//    //    content.sound = [UNNotificationSound defaultSound];
-//    //
-//    //    // 按冒号分割字符串为数组
-//    //    NSArray *timeArray = [@"10:51:00" componentsSeparatedByString:@":"];
-//    //
-//    //    // 从数组中取出时分秒的值
-//    //    NSInteger hour = [[timeArray objectAtIndex:0] integerValue];
-//    //    NSInteger minute = [[timeArray objectAtIndex:1] integerValue];
-//    //    NSInteger second = [[timeArray objectAtIndex:2] integerValue];
-//    //
-//    //    // 2. 设置触发条件 - 每天 9:00 AM
-//    //    NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
-//    //    dateComponents.hour = hour;
-//    //    dateComponents.minute = minute;
-//    //    dateComponents.second = second;
-//    //    UNCalendarNotificationTrigger *trigger = [UNCalendarNotificationTrigger triggerWithDateMatchingComponents:dateComponents repeats:YES];
-//    //
-//    //    // 3. 创建 notification request
-//    //    UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:@"DailyReminder" content:content trigger:trigger];
-//    //
-//    //    // 4. 添加ations
-//    //    // 创建允许按钮动作
-//    //        UNNotificationAction *allowAction = [UNNotificationAction actionWithIdentifier:@"ALLOW_ACTION" title:@"Allow" options:UNNotificationActionOptionForeground];
-//    //
-//    //        // 创建拒绝按钮动作
-//    //        UNNotificationAction *denyAction = [UNNotificationAction actionWithIdentifier:@"DENY_ACTION" title:@"Deny" options:UNNotificationActionOptionDestructive];
-//    //
-//    //        // 创建动作集合
-//    //    UNNotificationCategory *category = [UNNotificationCategory categoryWithIdentifier:@"NOTIFICATION_CATEGORY" actions:@[allowAction, denyAction] intentIdentifiers:@[@"ALLOW_ACTION",@"DENY_ACTION"] options:UNNotificationCategoryOptionCustomDismissAction];
-//    //
-//    //    // 5. 添加 notification request 到通知中心
-//    //    UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
-//    //    [[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:[NSSet setWithObject:category]];
-//    //
-//    //    [center addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {
-//    //        if (error != nil) {
-//    //            NSLog(@"Error adding notification request: %@", error);
-//    //        }
-//    //    }];
-//  });
-//}
-
-
 @end
 
 

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 1 - 1
ios/main.jsbundle


+ 18 - 31
src/features/trackTimeDuration/actions/TrackTimeActions.tsx

@@ -135,40 +135,27 @@ export const getLocalPush = () => {
             });
             PushNotification.cancelAllLocalNotifications()
 
-            messages.map(item => {
+            messages.map((item, index) => {
                 if (Taro.getSystemInfoSync().platform == 'ios') {
-                    // if (item.mode == 'ONCE') {
-                    //     PushNotification.localNotificationSchedule({
-                    //         //... You can use all the options from localNotifications
-                    //         channelId: item.id,
-                    //         title: item.title,
-                    //         message: item.content + '  ', // (required)
-                    //         date: new Date(item.once), // in 60 secs
-                    //         allowWhileIdle: true, // (optional) set notification to work while on doze, default: false
-                    //         messageId: item.id,
-                    //         // repeatType:'minute',
-                    //         /* Android Only Properties */
-
-                    //     })
-                    // }
-                    // else if (item.mode == 'RECURRING') {
-                    //     const { time, repeat_type } = item.recurring;
-                    //     const date = dayjs().format('YYYY-MM-DD')
+                    // if (index>0) return;
+                    setTimeout(() => {
                         var Jto = require('react-native').NativeModules.NativeBridge;
                         Jto.addLocalPush(item)
-                        // PushNotification.localNotificationSchedule({
-                        //     //... You can use all the options from localNotifications
-                        //     channelId: item.id,
-                        //     title: item.title,
-                        //     message: item.content + '  ', // (required)
-                        //     date: new Date(date + 'T' + time), // in 60 secs
-                        //     allowWhileIdle: true, // (optional) set notification to work while on doze, default: false
-                        //     messageId: item.id,
-                        //     repeatType: repeat_type,
-                        //     // repeatType:'minute',
-                        //     /* Android Only Properties */
-
-                        // })
+                    }, index * 1000)
+
+                    // PushNotification.localNotificationSchedule({
+                    //     //... You can use all the options from localNotifications
+                    //     channelId: item.id,
+                    //     title: item.title,
+                    //     message: item.content + '  ', // (required)
+                    //     date: new Date(date + 'T' + time), // in 60 secs
+                    //     allowWhileIdle: true, // (optional) set notification to work while on doze, default: false
+                    //     messageId: item.id,
+                    //     repeatType: repeat_type,
+                    //     // repeatType:'minute',
+                    //     /* Android Only Properties */
+
+                    // })
                     // }
                 }
                 else {

+ 1 - 1
src/features/trackTimeDuration/components/CheckAccess.tsx

@@ -281,7 +281,7 @@ export default function CheckAccess(props: { record: any, count: number }) {
                 break;
         }
 
-        console.error('失去资格弹窗', trigger_event, desc);
+        // console.error('失去资格弹窗', trigger_event, desc);
 
 
         setShowFastAlert(true)

+ 1 - 1
src/features/trackTimeDuration/components/IndexConsole.tsx

@@ -73,7 +73,7 @@ export default function IndexConsole(props: { record: any, count: number }) {
 
     useEffect(() => {
         if (process.env.TARO_ENV == 'rn') {
-            console.error('current status',status)
+            // console.error('current status',status)
             if (Taro.getSystemInfoSync().platform == 'ios') {
                 var Jto = require('react-native').NativeModules.NativeBridge;
                 var NativeAppEventEmitter = require('react-native').NativeAppEventEmitter;

+ 1 - 1
src/utils/time_format.ts

@@ -14,7 +14,7 @@ export class TimeFormatter {
   //获取时区偏移多少分钟
   static convertGMTtoOffset(gmtString) {
     if (!gmtString || (gmtString.indexOf('+') == -1 && gmtString.indexOf('-') == -1)) {
-      console.error('gmtString error', gmtString)
+      // console.error('gmtString error', gmtString)
       // return 0
       gmtString = 'GMT+0800'
     }

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio