Is deep linking supported in AMP
Description
I am trying to implement deep linking in AMP but could not get relevant documentation and solution. Could you please let me know if this is supported or not?
Reproduction Steps
I am trying to implement deep linking in AMP but could not get relevant documentation and solution. Could you please let me know if this is supported or not?
Relevant Logs
No response
Browser(s) Affected
No response
OS(s) Affected
No response
Device(s) Affected
No response
AMP Version Affected
No response
any update on this? its urgent requirement in my project. could you guys please let me know if this is possible in amp?
Hi @gskaushal92
What are you trying to accomplish exactly? If you'd like the possibility to open a resource entity within a native application as launched by the AMP document, please look into the <amp-app-banner> component.
Hi @alanorozco ,
Let me explain you my use case,
For the single anchor tag , I will have three URL's, one for iOS app, one for android app and one URL for the webbrowser. e.g
<a href ="..."
data-app-iOS ="..."
data-app-android ="...">
So now if I open my web application in a browser and click on the anchor tag, If device is iOS then it will redirect me to iOS app, if device is android device, then it will take me to android app. for the fallback scenario when app is not installed either it should take me to app store or the webbrowser URL.
I will have multiple anchor tag inside amp custom elements on a single page. I need to apply deep linking on all the anchor tags. So is this possible in amp?
any update on this issue?
I suppose <amp-app-banner> comes closest to this
@gskaushal92 You should use <amp-app-banner>
@gskaushal92 If amp-app-banner doesn't work for your use-case could you elaborate? You might also be able to use AMP Script for this case if necessary.
Here's an example of using amp-script with a fixed layout to achieve the effect outside of amp-add-banner.
Note this would only work for fixed or fixed-height layouts per https://amp.dev/documentation/components/amp-script/#user-gestures
<!DOCTYPE html>
<html ⚡>
<head>
<meta charset="utf-8" />
<title>My AMP Page</title>
<link rel="canonical" href="self.html" />
<meta name="viewport" content="width=device-width" />
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-script" src="https://cdn.ampproject.org/v0/amp-script-0.1.js"></script>
<style amp-custom>
h1 {
margin: 1rem;
}
</style>
<meta name="amp-script-src" content="sha384-waDDcEoaIQPS6zEDqHBMs9bHGNXNubnbxfMwZ7PMJISfomkcYICZrps8OR_KmDVH sha384-6CRZNs5xeP5LQ37BNmJnm5gfmsqLWLyFjwol7rBY-XQk6IVdBlob3zJeWj67xW_N sha384-aLxInsVzS82j-5KzGGsBhPgojL8levKmmX09xnJ6VxeRl1MuAm_k5rsUdgmzM0bm ">
</head>
<body>
<h1>Hello AMPHTML World!</h1>
<amp-script layout="fixed" height="30" width="100" script="platform-link">
<a href="foo.html" data-android="android.html" data-ios="ios.html">Link</a>
</amp-script>
<script id="platform-link" type="text/plain" target="amp-script">
const btn = document.querySelector('a');
if (/iPhone|iPad|iPod/i.test(navigator.userAgent)) {
btn.setAttribute('href', btn.getAttribute('data-ios'));
} else if (/Android/i.test(navigator.userAgent)) {
btn.setAttribute('href', btn.getAttribute('data-android'));
}
</script>
</body>
</html>
@kristoferbaxter Thanks. I have done it in the same way you have explained using amp-script. It is working fine.