I'm new to Cordova and JS and have been struggling with the InAppBrowser plug-in for Cordova 3.4.0 to work in iOS (Xcode v5.0.2).
The cordova project was built successfully using these command line commands:
cordova create InAppBrowserTest3-4 local.test InAppBrowser_Test3-4
cordova plugin add org.apache.cordova.inappbrowser
cordova platform add ios
cordova plugins
[ 'org.apache.cordova.inappbrowser' ]
www config file contains:
<feature name="InAppBrowser">
<param name="ios-package" value="CDVInAppBrowser" />
</feature>
Only these additional commands were added to the generated onDeviceReady method to exercise the InAppBrowser:
onDeviceReady: function() { app.receivedEvent('deviceready');
//added these lines below
alert('deviceReady');
var ref = window.open('http://apache.org', '_blank', 'location=yes');
ref.addEventListener('loadstart', function(event) { alert('start: ' + event.url); });
ref.addEventListener('loadstop', function(event) { alert('stop: ' + event.url); });
ref.addEventListener('loaderror', function(event) { alert('error: ' + event.message); });
ref.addEventListener('exit', function(event) { alert(event.type); });
alert('end deviceReady');
}
When executed, the last alert isn't called and no browser is open. Similar code is running successfully using Cordova 2.9.0.
Does anyone have any suggestions? I've read through several similar posts but haven't found a solution yet.
To solve this, try the following:
cordova create hello com.example.hello HelloWorld
cd hello
cordova platform add android
cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser.git
cordova build
Note the "cordova build" step, which creates the platform/ios/www
directory where you can find the file cordova_plugins.js
with the folder plugins correctly installed.