Search code examples
iphonecordovachildbrowser

Childbrowser with Cordova 1.7 iPhone issue


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.


Solution

  • 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;
     }