views:

159

answers:

3

I know that i can use the following code to launch my own url, but i want the user to continue their workflow after using my bookmarklet so therefore don't want to open a new tab and have them re-load the url i put into the url variable?

NSURL url* = [NSURL URLWithString:@"http://google.com"];
[[UIApplication sharedApplication] openUrl:""];

Can this be done?

+2  A: 

There is no way to open Safari without actually quitting your app and opening Safari. Or to somehow automatically return the user to your app from Safari once the URL you opened loads.

Or am I misunderstanding the question?

Sixten Otto
Kind of, i just want to LAUNCH the app without a url, not with one of mine - simply launch it
tarnfeld
Ah. No, you can't do that either. Mostly because not every URL you might pass to -openURL: will open Safari. For example, "tel:" URLs open the phone app. http://wiki.akosma.com/IPhone_URL_Schemes
Sixten Otto
Ah right ;) I see - ok, thanks!
tarnfeld
A: 

Actually, you can delegate a URL handler to your app. A smart example is shown here: http://www.mobileorchard.com/lite-to-paid-iphone-application-data-migrations-with-custom-url-handlers/

The scenario is: - register URL handler - open Safari as normal - get Safari to use your custom URL handler that should open your app (eg: myapp://)

Have a look at the way Flickr iPhone app does the authentication.

Paul Ardeleanu
A: 

Can you use 'about:blank' as the url? That should just open Safari with a blank page. I assume this would be similar to tapping the 'number' button in the bottom right then selecting 'new page'.

slugolicious