如果您的電子郵件中包含iframe
的網頁,並且src
設置爲您的應用的自定義方案,則iOS會自動重定向到應用中的該位置。如果應用程序未安裝,則不會發生任何事情。這允許您深入鏈接到應用程序(如果它已安裝),或者如果未安裝,則重定向到App Store。
例如,如果您安裝了twitter應用程序,並導航到包含以下標記的網頁,您將立即轉到該應用程序。如果您沒有安裝Twitter應用程序,則會看到文字「Twitter應用程序未安裝」。
<!DOCTYPE html>
<html>
<head>
<title>iOS Automatic Deep Linking</title>
</head>
<body>
<iframe src="twitter://" width="0" height="0"></iframe>
<p>The Twitter App is not installed</p>
</body>
</html>
這裏,如果沒有安裝應用程序重定向到App Store進行更徹底的例子:
<!DOCTYPE html>
<html>
<head>
<title>iOS Automatic Deep Linking</title>
<script src='//code.jquery.com/jquery-1.11.2.min.js'></script>
<script src='//mobileesp.googlecode.com/svn/JavaScript/mdetect.js'></script>
<script>
(function ($, MobileEsp) {
// On document ready, redirect to the App on the App store.
$(function() {
if (typeof MobileEsp.DetectIos !== 'undefined' && MobileEsp.DetectIos()) {
// Add an iframe to twitter://, and then an iframe for the app store
// link. If the first fails to redirect to the Twitter app, the
// second will redirect to the app on the App Store. We use jQuery
// to add this after the document is fully loaded, so if the user
// comes back to the browser, they see the content they expect.
$('body').append('<iframe class="twitter-detect" src="twitter://" />')
.append('<iframe class="twitter-detect" src="itms-apps://itunes.com/apps/twitter" />');
}
});
})(jQuery, MobileEsp);
</script>
<style type="text/css">
.twitter-detect {
display: none;
}
</style>
</head>
<body>
<p>Website content.</p>
</body>
</html>
我認爲理想的解決方案將意味着你可以重定向到iTunes的鏈接與指令。就像:https://itunes.apple.com/us/app/clear/id492134154?mt=8&uo=4&open=true where open = true告訴iOS應用程序商店打開應用程序... – ConfusedNoob