0

Can any expert here please point me to some valid walkthrough on how to make the ChildBrowser work with Cordova 1.7 in iPhone? I have found lots of documents and blogs out there that tell you how to do it, but none of them have worked for me. It is not a whitelist issue for sure, as for the time being I have set it to the wildcard *, so whitelisting problems can be safely ruled out I guess. In some cases, ChildBrowser was successfully installed, but when I called the showwebpage function, it just would not show up (there wouldn't be any errors either!). Other times, it just won't even install. I have already spent 2 days on it, and am still clueless. Just hoping if you could help me out. Any help would be appreciated.


I could finally get the ChildBrowser to open up following what Dhawal has suggested below. But the onLocationChange event never seems to fire. Again, this seems to be a common problem with Cordova 1.7. Any workarounds apart from rolling back to some older Cordova version? Any help would be appreciated.

Here's what I am trying to do:

window.plugins.childBrowser.showWebPage(url, { showLocationBar: true });
window.plugins.childBrowser.onLocationChange = function(loc){ alert("In index.html new loc = " + loc); };

Ok, got it to work. Seems like ChildBrowser is still compatible with older versions of Cordova only. Had to delve into Objective-C and make changes in the plugin to make it work.

dda
  • 6,030
  • 2
  • 25
  • 34
avikbagh
  • 43
  • 1
  • 7

1 Answers1

3

I have a basic application which has childbrowser integration with Cordova 1.7. I have put the steps also to generate build same application.

ios-cordova-childbrowser

Edit

Childbrowser events were not getting called properly so I added this fix in ChildBrowser.js file to resolve it.

if (cordovaRef && cordovaRef.addConstructor) {
    cordovaRef.addConstructor(ChildBrowser.install);

    // Make ChildBrowser global
    window.ChildBrowser = ChildBrowser;
 } else {
    console.log("ChildBrowser Cordova Plugin could not be installed.");
    return null;
 }
dhaval
  • 7,611
  • 3
  • 29
  • 38
  • 1
    Awesome, thanks a lot, works like a charm now. I would also vote up if i had the reputations :) – avikbagh Jun 15 '12 at 09:15
  • Can you please help me with my latest roadblock now? Please see the edit. – avikbagh Jun 15 '12 at 11:52
  • i have fixed the project and updated the github source, also adding the change in the answer if you want to just add the fix – dhaval Jun 15 '12 at 13:03
  • let me know if it works for you, it is calling proper events in my setup – dhaval Jun 15 '12 at 13:06
  • Yes it does, this seems simpler than making changes in the .m files of the plugin, which is what i did in trying to get it to work. Again, thanks a lot. – avikbagh Jun 18 '12 at 08:17
  • @dhaval, voted it up. thank you for the elegant one-line fix in childbrowser.js. I am a newbie and don't know how to do this. But it would help a lot of people if, your fix at: https://github.com/dhavaln/cordova-examples/blob/master/ios-cordova-childbrowser/www/ChildBrowser.js can be pulled into https://github.com/phonegap/phonegap-plugins/blob/master/iOS/ChildBrowser/ChildBrowser.js. It took a a while to stumble upon your fix. Thanks again. – GeorgeW Jul 09 '12 at 22:09