Cordova shows an warning as “ THREAD WARNING: [Your function] took [n] ms. ” in iOS

前端 未结 2 1931
闹比i
闹比i 2021-02-05 16:02
 \"THREAD WARNING: [\'Console\'] took \'81.661865\' ms. Plugin should use a  background thread.\"

While running iOS Phonegap project.

2条回答
  •  悲&欢浪女
    2021-02-05 16:26

    As per this. solved my warning issue

    I found warning can be ignored .But this can be solved by adding background thread using this loop:(In CDVLogger.m)

     [self.commandDelegate runInBackground:^{
    
        //add your code here
     }
    

    Now this looks as below for console warning:

    - (void)logLevel:(CDVInvokedUrlCommand*)command
     {
       [self.commandDelegate runInBackground:^{
       id level = [command argumentAtIndex:0];
       id message = [command argumentAtIndex:1];
    
      if ([level isEqualToString:@"LOG"]) {
        NSLog(@"%@", message);
      } else {
          NSLog(@"%@: %@", level, message);
       }
     }];
    }
    

提交回复
热议问题