0

I'm developing a phonegap/cordova 2.9 iOS App with jQuerymobile which some links need to open a url with InAppBrowser. Also I've integrated Google Admob. Navigation is basic single page template with some different html pages.

When App is loaded, if I don't go to other sections of the app, when press buttons with In-App Browser URLS, In-App Browser opens. But if I go to other sections of the app and go again to index.html, In-App Browser fails and not working.

Different sections of the App are linked with target="_blank". If I link sections without target="_blank", all works correctly, but I need use target="_blank" to go back to index.html and reload XML data.

I'm searching any solution some days ago but I haven't find anything. Only one similar detailed in this post, but without solution: http://iphonedevsdk.com/forum/iphone-sdk-development/115057-inappbrowser-is-not-opening.html

Another thing I've tried is install Childbrowser Plugin from https://build.phonegap.com/plugins/2 and use it instead of In-App Browser, but I can“t make it work.

Can anybody Help me?. Thank you very much.

1 Answers1

0

You may have moved on from this, but my scenario was that I was using Cordova 2.9.1 with jquery mobile. At certain points in the user experience I also go back to index.html. This worked fine unless I opened InAppBrowser at any point. InAppBrowser worked, but the next time I went back to a refresh of index.html, all plugins including InAppBrowser would not execute.

My fix was to make a change to CDVInAppBrowser.m as follows:

Instead of:

BOOL isPDF = [@"true" isEqualToString :[theWebView stringByEvaluatingJavaScriptFromString:@"document.body==null"]];
if (isPDF) {
    [CDVUserAgentUtil setUserAgent:_prevUserAgent lockToken:_userAgentLockToken];
}

[self.navigationDelegate webViewDidFinishLoad:theWebView];

I took out the isPDF logic and just made sure that it always updated to the previous UserAgent. I was left with just..

[CDVUserAgentUtil setUserAgent:_prevUserAgent lockToken:_userAgentLockToken];

[self.navigationDelegate webViewDidFinishLoad:theWebView];

Hope this helps someone who may have been in a similar scenerio of InAppBrowser breaking jquery-mobile or similar frameworks when cordova.js was reloaded again.

ryanH
  • 86
  • 3