PDA

View Full Version : Comming back to the app after launching safari




cyberserker
Apr 23, 2009, 02:55 AM
I put some links in my app that launch safari when asked:


- (IBAction)jumpToUrl:(id)sender {
UIButton *url = (UIButton *)sender;
NSString *urlString = [NSString stringWithFormat:@"http://%@", url.currentTitle];
if (![[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]])
{
// there was an error trying to open the URL. for the moment we'll simply ignore it.
}
}


Unfortunately, the backbutton in safari is inactive with no means to the user to go back to the app.

Any idea?



robbieduncan
Apr 23, 2009, 03:23 AM
The back button is not meant to take the user back to your app: it's for browsing backwards in the browser history. If the user wants to come back to your app they hit the home button and launch your app again. Just like any other app.

cyberserker
Apr 23, 2009, 04:14 AM
In fact, it is possible using the Google App!!!

I tried it yesterday and it works well, giving the user the opportunity to go back and forth between safari and Google App.

robbieduncan
Apr 23, 2009, 04:29 AM
Well then I'd suggest asking Google how they do it as there is no direct support for it in the SDK. The only way I can see of doing it is to register a URI scheme for you app and somehow arrange for this to be added to the browser history stack in the correct place (via javascript possibly).

robbieduncan
Apr 23, 2009, 04:34 AM
I've just installed the Google app. They appear to do this by directing you to a special site first (at a specific IP address, no doubt on they control) which then redirects you to the site you wanted. When you hit back you go to that site and it then re-launches the Google app (via a registered URL handler on the phone).

So there you go: if you want to do this you now know how.