I'm a complete Phonegap newbie so go easy on me if you can :)
I've got phonegap 1.5 installed and running fine. I struggled to install the childbrowser plugin but I believe it's correctly installed now. However, I can't seem to get the childbrowser to show? I've tried following various tutorials here (http://bit.ly/ifK9lM) and here (http://bit.ly/wOlq6k). I don't get any build errors or console errors but the child browser just doesn't show when I click on a link.
All I get in the console when I click my button is "Opening Url: http://www.google.com". So it's as if it's trying...but I just get no visual output??
I have the ChildBrowser.js file in the root of my www folder alongside the cordova.js file. I have all the Child browser plugin files added to my plugin folder in xcode.
I am using Xcode 3.2.6
If anyone can suggest what I am doing wrong that'd be much appreciated.
I can't post all related code here because it'd just get out of hand. Happy to post 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's Cordova!</h1>
<button onclick="openChildBrowser('http://www.google.com');">Open Google</button>
</body>
</html>