你如何使PhoneGap IOS插件在后台线程中运行

时间:2014-10-23 13:40:17

标签: jquery ios xcode multithreading cordova

在xCode 6.1中,为IOS运行Cordova 3.6.0我收到警告,插件应该在后台线程中运行。

我的问题是如何在后台线程中运行File,Camera,NetworkStatus,StatusBar,Notification和EmailComposer插件?

我很感激一些帮助。下面是我在xCode控制台中获得的输出。

2014-10-23 06:56:13.683 BackTracker[1689:462317] Multi-tasking -> Device: YES, App: YES 

2014-10-23 06:56:13.726 BackTracker[1689:462317] Unlimited access to network resources 

2014-10-23 06:56:13.739 BackTracker[1689:462317] Started backup to iCloud! Please be careful. Your application might rejected by Apple if you store too much data. For more information please read "iOS Data Storage Guidelines" You could find it at the following address https://developer.apple.com/icloud/documentation/data-storage/ .

2014-10-23 06:56:14.002 BackTracker[1689:462317] [CDVTimer][file] 78.798950ms 

2014-10-23 06:56:14.137 BackTracker[1689:462317] [CDVTimer][splashscreen] 133.718014ms

2014-10-23 06:56:14.147 BackTracker[1689:462317] [CDVTimer][statusbar] 9.751022ms

2014-10-23 06:56:14.148 BackTracker[1689:462317] [CDVTimer][TotalPluginStartup] 224.672019ms 

2014-10-23 06:56:14.432 BackTracker[1689:462317] Resetting plugins due to page load. 

2014-10-23 06:56:16.520 BackTracker[1689:462317] Finished load of: file:///private/var/mobile/Containers/Bundle/Application/532EB1D5-B92A-4939-9FBD-C1EB1E8962CD/BackTracker.app/www/index.html

2014-10-23 06:56:16.709 BackTracker[1689:462317] THREAD WARNING: ['NetworkStatus'] took '54.156250' ms. Plugin should use a background thread. 

2014-10-23 06:56:16.734 BackTracker[1689:462317] THREAD WARNING: ['StatusBar'] took '22.954102' ms. Plugin should use a background thread. 

2014-10-23 06:57:02.175 BackTracker[1689:462317] Application tried to represent an active popover presentation: <UIPopoverPresentationController: 0x17dd0900> 

2014-10-23 07:00:14.995 BackTracker[1689:462317] THREAD WARNING: ['File'] took '10.078857' ms. Plugin should use a background thread. 

2014-10-23 07:00:15.081 BackTracker[1689:462317] THREAD WARNING: ['EmailComposer'] took '56.955078' ms. Plugin should use a background thread.

1 个答案:

答案 0 :(得分:0)

Cordova有几种方法可以调用本机插件(Native Bridge Mode)。

尝试使用XHR OPTIONAL PAYLOAD而不是默认值 刚刚在deviceready事件之后的IFRAME_NAV。

exec.setJsToNativeBridgeMode(exec.jsToNativeModes.XHR_OPTIONAL_PAYLOAD);

更多信息: https://github.com/phonegap/phonegap/blob/master/lib/ios/guides/Changing%20the%20JavaScript%20to%20Native%20Bridge%20Mode.md