Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is PhoneGap on iOS hard coded to load www/index.html?

Tags:

ios

cordova

On PhoneGap on Android you can modify the App.java class to load any url. I can't find anywhere to change the entry point on the iOS version.

When testing I prefer to have a few "www" directories with different setups. At the moment I need to rename the directories which is a bit of a nuisance.

like image 284
Tim Avatar asked Nov 09 '11 10:11

Tim


4 Answers

As of PhoneGap 2.2, you can now override the <content> tag in your config.xml:

<content src="http://www.example.com" />
like image 160
Waynn Lue Avatar answered Nov 15 '22 21:11

Waynn Lue


PhoneGapDelegate.h defines a class method startPage which you can overload/redefine in your iOS app's AppDelegate.m file.

+ (NSString*) startPage;

For example:

+ (NSString*) startPage{ 
    return @"http://m.google.com";
}

Will redefine the start page in PhoneGap. You will have to add google.com to your ExternalHosts in PhoneGap.plist. As of PhoneGap 1.2 If you do this and include Plugins in your native app, remotely host PhoneGap apps and their related *.js WILL be able to preform plugin actions. I've tested this with BarcodeScanner, ChildBrowser and ApplicationPreferences.

UPDATE

As of 1.4.0 and 1.4.0, startPage and wwwFolderName are properties instead of methods. They are still redefinable, but you can no longer have startPage point to a remote (non-local) phonegap installation like in my above example. (Which is kind of a bummer)

like image 45
mtwagner Avatar answered Nov 15 '22 19:11

mtwagner


You could do this:

Create the default index.html and have it wrap and load your own html root file, that way you can keep your own directory structure and no need to do any modifications there.

Of course, phonegap is open source, so you could also commit a change to phonegap to change the iOS api similar to Android API. Currently it seems the root html file path is determined in class PhoneGapDelegate.m

like image 42
Hannes R. Avatar answered Nov 15 '22 21:11

Hannes R.


you could do it

class/ AppDelegate.m

change self.viewController.startPage to ur startpage in AppDelegate.m

like image 36
Vinay Avatar answered Nov 15 '22 19:11

Vinay