ios - THREAD WARNING - phonegap -
thread warning: ['notification'] took '1153.449951' ms. plugin should use background thread. how solve? me please!
cordova's official documentation states that:
if plugin requires great deal of processing or requires blocking call, should use background thread.
use code this:
- (void)mypluginmethod:(cdvinvokedurlcommand*)command { // check command.arguments here. [self.commanddelegate runinbackground:^{ nsstring* payload = nil; // blocking logic... cdvpluginresult* pluginresult = [cdvpluginresult resultwithstatus:cdvcommandstatus_ok messageasstring:payload]; // sendpluginresult method thread-safe. [self.commanddelegate sendpluginresult:pluginresult callbackid:command.callbackid]; }]; }
Comments
Post a Comment