Phonegap 1.5 (Cordova) ios childbrowser not opening at all

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> 
+6
source share
5 answers

Brad

I had the same problem as you, and I realized that before I added the files to Xcode. Make sure you actually drag and drop files into the Plugins folder in Xcode - don't just put them in the folder itself.

Also make sure you add the .xib file. If you follow the instructions here: http://blog.digitalbackcountry.com/2012/03/installing-the-childbrowser-plugin-for-ios-with-phonegapcordova-1-5/ , it only mentions adding a .h file, .m and bundle, but from the screenshot you can see that the xib file is there too.

You may also need to upgrade to Xcode 4 - works for me on Xcode 4.2 and Cordova 1.5

+6
source

You do not need to change anything in the appdelegate file. No import, no code changes, nothing. Just copy the OS-specific files to the Plugin directory, change the Cordova.plist file and copy the JS files to the www folder. And you must be installed.

Let me know if this helps - http://blog.digitalbackcountry.com/2012/03/installing-the-childbrowser-plugin-for-ios-with-phonegapcordova-1-5/

+3
source

Try calling a function to display the page as follows:

window.plugins.childBrowser.showWebPage (URL);

What key and value have you added to your Cordova.plist file? Do you remember the one that was for external hosts?

0
source

I do not think that Childbrowser works with Cordova (1.5).

You must use the telephone conversation 1.4.1. Here you have examples for 1.4.1: https://github.com/RandyMcMillan/CDVPluginDemos

If anyone has a job with Cordova, please post some examples here:

0
source

I use the same plugin that Ryan Stewart uses and it works. He wrote a good article to test it. I managed to get it to work with readme files in the plugins folder, there are several small mods that you need to do.

In addition, you may have to upgrade the version of Xcode. For me, this worked on 4.2, and now I am on 4.3.1. But if you are using an earlier version, you may have to jump

Make sure you also followed the Update Cordoba document when installing Cordoba itself. Read everything carefully, because I had a problem installing the plugin, and not with the plugin itself.

Good luck

0
source

Source: https://habr.com/ru/post/910651/


All Articles