- Home /
Childbrowser not working with Unity and Phonegap
Hello Everyone,
I am building a iPhone App that uses UNITY3D and phonegap. I have used a basic Unity3D Iphone xcode project, and added some of the native and java code from Gregg's Native UI to Unity project (http://clevermartian.com/blog/?p=59). I then added the files (class files and www folder, etc.)from phone gap to the project. The current result allows me to move successfully from unity to phonegap.
I now need to move from phonegap back to Unity, which should be relatively easy using childbrowser to move from phonegap back to an XIB, where I could call the Unitymessage function. My issue is that I cant get childbrowser to work. I have installed it as directed by their site (changed plist keys, put files in plugin folder, added the link to index, etc.), yet there still seems to be no connection between phonegap and childbrowser. I have created a temporary solution by just adding a button on the phonegap webview xib that allows me to return to unity, but this solution is always on the screen while phonegap is running which is not the desired result. Does anyone have suggestions on how to get childbrowser working for this project?
Thank you in advance for your advise.
-Alex
Answer by Alex1200 · Nov 16, 2012 at 06:43 PM
Hello Again, I solve my problem. I decided not to use Childbrowser in my project becasue I couldnt get it working. Instead I set up a listener in my viewcontroller for the html page, part of it follows:
if(requestString != nil){
if([requestString rangeOfString:@"#"].location != NSNotFound){
NSArray* foo = [requestString componentsSeparatedByString: @"#"];
int* number = 0;
for (int i = 0, count = [foo count]; i < count; i = i + 1)
{
number+=1;
}
if (number == 2);
NSString* day = [foo objectAtIndex: 1];
NSString *cheater = @"cphotos";
if([day isEqualToString:cheater]){
NSLog(@"OpenUnity");
//Here it then calls the Unity Message command to go back to unity like is done in Gregg's Native UI to Unity project.
This was placed in: - (BOOL)webView:(UIWebView )webView2 shouldStartLoadWithRequest:(NSURLRequest )request navigationType:(UIWebViewNavigationType)navigationType {
So when the user navigated to the 'cphotos' (index.html#cphotos) page they would be forwarded to unity. I also included a 'window.location' in the html for that page to reset the html back to my home page. I am not a programmer so this might not be the most elegant solution but it does allow me to go from unity to html (phonegap) and back in a single app. Hope this helps anyone trying to do similar things, I can try to share more of the process if there is interest.
Your answer
![](https://koobas.hobune.stream/wayback/20220613082044im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Z-index issues 2 Answers
How to perform a task in a specified time 2 Answers
Unity on Google TV?? 3 Answers
ARCamera Issue when migrating to Qualcomm Augmented Reality vuforia-unity-android-ios-3-0-6 1 Answer