I'm a complete newbie to Phonegap, so it's easy on me if you can :)
I have a 1.5 phone saver installed and working. I struggled to install the childbrowser plugin, but I believe that it is installed correctly now. However, it seems that I can not show the child what he can show? I tried various tutorials here ( http://bit.ly/ifK9lM ) and here ( http://bit.ly/wOlq6k ). I am not getting build errors or console errors, but the child browser just does not appear when I click the link.
All that I get in the console when I click the "Open" button: http://www.google.com ". So, as if it is trying ... but I just do not get visual output?
I have a ChildBrowser.js file in the root of my www folder next to cordova.js. I have all the plugins files for the Child browser added to my plugins folder in xcode.
I am using Xcode 3.2.6
If someone can suggest that I am doing wrong, that would be greatly appreciated.
I can't post all the related code here because it just got out of hand. With pleasure send the requested code.
Here is my current appdelegate.h file:
#import "AppDelegate.h" #import "MainViewController.h" #ifdef CORDOVA_FRAMEWORK #import <Cordova/CDVPlugin.h> #import <Cordova/CDVURLProtocol.h> #else #import "CDVPlugin.h" #import "CDVURLProtocol.h" #endif #import "ChildBrowserCommand.h" #import "ChildBrowserViewController.h" @implementation AppDelegate @synthesize invokeString, window, viewController; //Code excluded for brevity here..... #pragma UIWebDelegate implementation - (void) webViewDidFinishLoad:(UIWebView*) theWebView { // only valid if FooBar.plist specifies a protocol to handle if (self.invokeString) { NSString* jsString = [NSString stringWithFormat:@"var invokeString = \"%@\";", self.invokeString]; [theWebView stringByEvaluatingJavaScriptFromString:jsString]; } // Black base color for background matches the native apps theWebView.backgroundColor = [UIColor blackColor]; return [self.viewController webViewDidFinishLoad:theWebView]; } - (void) webViewDidStartLoad:(UIWebView*)theWebView { return [self.viewController webViewDidStartLoad:theWebView]; } - (void) webView:(UIWebView*)theWebView didFailLoadWithError:(NSError*)error { return [self.viewController webView:theWebView didFailLoadWithError:error]; } - (BOOL) webView:(UIWebView*)theWebView shouldStartLoadWithRequest: (NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType { return [self.viewController webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType]; } - (void) dealloc { [super dealloc]; } @end
Here is my index.html:
<!DOCTYPE html> <html> <head> <title></title> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" /> <meta charset="utf-8"> <script type="text/javascript" charset="utf-8" src="cordova-1.5.0.js"></script> <script type="text/javascript" charset="utf-8" src="ChildBrowser.js"></script> <script type="text/javascript"> var childBrowser; function onBodyLoad() { document.addEventListener("deviceready", onDeviceReady, false); } function onDeviceReady() { childBrowser = ChildBrowser.install(); } function openChildBrowser(url) { try { childBrowser.showWebPage(url); } catch (err) { alert(err); } } </script> </head> <body onload="onBodyLoad()"> <h1>Hey, it Cordova!</h1> <button onclick="openChildBrowser('http://www.google.com');">Open Google</button> </body> </html>
source share