Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone apps: Can I open an app from a link in a website?

Tags:

iphone

I'm a newbie iPhone developer, writing an app that will kind of be the "mobile version" of a website.

I'm wondering whether it's possible to launch my app from a link in a website. So, for example, someone goes into our site in the iPhone Safari, clicks a link, and our app launches.

Is that possible?
If so can I also "pass parameters" to the app i'm launching? As in...
Clicking different links would allow them to get different stuff in the app at launch time.

Thanks!
Daniel

like image 539
Daniel Magliola Avatar asked Jan 19 '10 17:01

Daniel Magliola


People also ask

Can you open an app with a link?

Open Links Directly in App And Not Browser On Android. On Facebook, YouTube, and Twitter for Android, every link you click opens in the in-app browser by default.


3 Answers

Certain apps have URL schemes that will launch them. If an app has published this scheme (or if you dig around in their bundle) you can launch it. For example, a hypothetical twitter app might launch with a twitterapp://here+is+my+tweet URL. If you preload your app with the correct URL scheme, you can do this for yours, too.

Here's a sample URL scheme from the info.plist:

<key>CFBundleURLTypes</key> <array>     <dict>         <key>CFBundleURLName</key>         <string>com.standalone.cooltwitterapp</string>         <key>CFBundleURLSchemes</key>         <array>             <string>twitterapp</string>         </array>     </dict> </array> 
like image 142
Ben Gottlieb Avatar answered Sep 19 '22 22:09

Ben Gottlieb


Yes you can, using custom URI schemes. Do note, however, that clients without the app will not be able to use the links.

If so can I also "pass parameters" to the app i'm launching?

Again, yes. Once your app has registered for a given scheme it's all yours.

like image 24
jensgram Avatar answered Sep 21 '22 22:09

jensgram


Also worth noting is that the application:openURL:sourceApplication:annotation: method will be called when your app launches from a URL. Details at Apple's Docs.

like image 41
bmalicoat Avatar answered Sep 18 '22 22:09

bmalicoat