Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
228 views
in Technique[技术] by (71.8m points)

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...