I'm developing an hybrid app in phonegap and basically I have a button in the index page which whenever is clicked opens up an external url. I succeed on Android and fail on iOS.
I've looked up these questions iOS / Cordova: InAppBrowser not working - cordova/phonegap onclick doesn't work - PhoneGap Build: how to open external url in device browser on Android? - phonegap open link in browser but unfortunately none of these questions helped me to fix the issue.
First hypothesis could be an error message alert : The error message
on the iPhone where I'm testing my app is: [ERROR] Error initializing
Cordova: Missing Command Error
.
Second hypothesis I'm doing something wrong with the onclick
event of the window.open
method because when I click the open button on the iOS test device nothing happens.
Here is the code:
document.getElementById("openBrowser").addEventListener("click", function(){
var ref = window.open('http://www.espn.com', '_self', '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); });
});
<button id="openBrowser">APRI</button>
As you can see the above piece of code works and works on the google ripple emulator too and as I said earlier at the beginning of my question it works also on Android (link to the android web app https://play.google.com/store/apps/details?id=com.phonegap.unoxtutti&hl=it) As a matter of fact I'm not sure what problem may be behind this malfunctioning either the former or the latter hypothesis.
Besides the cordova plugin inappbrowser is in config.xml
<plugin name="org.apache.cordova.inappbrowser" />
I'm really unable to find the bug but I hope to have provided you the necessary information to help me to fix this seemingly insolvable problem
The test environmemts are Google Ripple Emulator, Phonegap Desktop App and the Phonegap Mobile App. The desktop app creates the directory of the project while the mobile app and the google ripple emulator are connected to the desktop app and are my test environments. Last but not least on the ripple emulator the external url successfully opens up while it doesn't on the mobile app and the initialization error
throws when the app is opened.