I have created a mobile app using jQuery Mobile and built it for iOS and Android via PhoneGap Build v2.5. I then successfully added inmobi advertisements using their javascript api. The ad displays just fine but the problem comes when a user clicks the ad as the ad takes over the app. This isn't such an issue in Android as users have a back button but on iOS devices the user is stuck and unable to get back to my app.
I have successfully set up all external links contained in my app to open in the device's browser by passing all url's to this function:
function openNewBrowser(url) {
window.open(encodeURI(url), '_system');
return false;
}
But the inmobi ad is inside of an iframe in my app and I have no control over how they pass their url's. I have also tried to bind jQuery Mobile to catch all pagebeforechange events and process them accordingly using:
$(document).bind("pagebeforechange", function(e, data) {
if(typeof data.toPage === 'object' ||
data.toPage.indexOf("index.html#") >= 0) {
//internal URL so do nothing
} else {
//external URL so send to openNewBrowser
console.log('page is external');
openNewBrowser(data.toPage);
e.stopPropagation();
return false;
}
});
but the "else" is never tripped. The inmobi ad just takes over the app and user is forced to kill and restart the app back to a usable state. Is there a different event I should be listening for?
Here is how I am calling the inmobi ad:
var inmobi_conf = {
siteid : "*******mySiteId*******",
slot : "15",
manual: true,
test: true,
targetWindow: "_blank"
};
I would (and have tried to) set the "targetWindow" to _system but the only valid parameters are "_blank" and "_top".
Does anyone know of a way to get iFrame links (that you cant set to _system) to open in the native browser instead of taking over the app or gotten inmobi ad's to not take over the app?