Working Web Browser code
by Dave Young · in iTorque 2D · 04/07/2009 (10:18 am) · 6 replies
The placeholder code for opening Safari is missing, here is some that works:
bool Platform::openWebBrowser( const char* webAddress )
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithUTF8String: webAddress]]];
return true;
}
#2
04/07/2009 (7:36 pm)
Do a full text search for it, this function already exists but it empty
#3
04/10/2009 (12:34 pm)
I need to link to the app store from my app. I'd like to point to the full version from the free version. Is openURL the best way to do this?
#4
04/10/2009 (1:06 pm)
UIApplication's openURL is the only way, from what the docs tell me.
#5
gotoWebPage() is in the consoleFunctions.cc file. It ends up calling openWebBrowser() which is in platformiPhone\iPhoneWindow.mm. This is how I have it set up:
I don't remember if I got the code in openWebBrower() from here on GG's forums or somewhere else, but it worked for me.
04/11/2009 (1:07 pm)
Here is how I did it in my conga drum game and it is working. Here is the torque script part (I actually had the app store loc set up in main.cs, but put it here so you can see the format that I used):$APP_STORE_IBABALU = "itms://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=308792705&mt=8";
function mmBuyFullVersion::onMouseDown(%this)
{
gotoWebPage($APP_STORE_IBABALU);
}gotoWebPage() is in the consoleFunctions.cc file. It ends up calling openWebBrowser() which is in platformiPhone\iPhoneWindow.mm. This is how I have it set up:
bool Platform::openWebBrowser( const char* webAddress )
{
NSString *string = [[NSString alloc] initWithUTF8String: webAddress];
NSURL *url = [[NSURL alloc] initWithString: string];
bool ret = [platState.application openURL: url];
[string release];
[url release];
return ret;
}I don't remember if I got the code in openWebBrower() from here on GG's forums or somewhere else, but it worked for me.
#6
04/11/2009 (4:27 pm)
Awesome! Thanks. It turns out that I too wrote a conga app called iConga. Great minds think alike.
Torque Owner Ronald Ian Bantayan