简体   繁体   English

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

[英]How do you make PhoneGap IOS plugins run in a background thread

In xCode 6.1, running Cordova 3.6.0 for IOS I am getting warning that plugins should be run in a background thread. 在xCode 6.1中,为IOS运行Cordova 3.6.0,我得到警告,插件应该在后台线程中运行。

My question is how do you make the File, Camera, NetworkStatus, StatusBar, Notification and EmailComposer plugins run in a background thread? 我的问题是如何使File,Camera,NetworkStatus,StatusBar,Notification和EmailComposer插件在后台线程中运行?

I would appreciate some help. 我将不胜感激。 Below is the output I am getting in the xCode console. 以下是我在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.

Cordova has several ways to call native plugins (Native Bridge Mode) . Cordova有几种调用本机插件的方法(本机桥接模式)。

Try using XHR OPTIONAL PAYLOAD instead the default IFRAME_NAV just after deviceready event. 在设备就绪事件发生后,尝试使用XHR OPTIONAL PAYLOAD代替默认的IFRAME_NAV。

exec.setJsToNativeBridgeMode(exec.jsToNativeModes.XHR_OPTIONAL_PAYLOAD); exec.setJsToNativeBridgeMode(exec.jsToNativeModes.XHR_OPTIONAL_PAYLOAD);

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM