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

我的梦境 提交于 2019-12-03 02:24:30

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);
   }
 }];
}

Also to add,

If someone is looking for a way to run sepcifically the Geolocation plugin as a background thread with iOS Cordova there is a fix on GitHub.

It removes the Xcode output warning: "THREAD WARNING: ['Geolocation'] took 'X' ms. Plugin should use a background thread."

Download the plugin from here: https://github.com/guillaumedev/cordova-plugin-geolocation

Heres whats changed (runInBackground added): https://github.com/guillaumedev/cordova-plugin-geolocation/commit/8fbceca845441f4f421548f243d2f05573d11225

More information about Cordova Threading: https://cordova.apache.org/docs/en/dev/guide/platforms/ios/plugin.html#threading

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!