且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何禁用“在应用程序中打开" iOS Safari中的横幅广告是否支持通用链接?

更新时间:2023-01-01 18:18:37

在下面的回答中,我意识到只有在未安装应用程序时才能加载.您试图实现的目标可能无法实现.由于AASA文件已安装在设备上,因此Safari会自动将该网页与应用程序相关联,从而将横幅广告加载到浏览器中.我不认为这是一个HTML元素,您只能通过JQuery调用将其删除.解决方案是将重定向链接用作通用链接.这样,如果安装了该应用程序,则该应用程序将打开,如果未安装,它将重定向到您的站点,该站点不会被识别为通用链接,也不会显示横幅. 分支是使用重定向的可靠的深层链接解决方案,因此您不必处理Apple横幅广告. /p>

未安装应用程序时删除标语

确保没有在页面上加载智能应用程序横幅广告元标记.如果看到此标签,请将其取出:

<meta name="apple-itunes-app" content="app-id=myAppStoreID, affiliate-data=myAffiliateData, app-argument=myURL">

After registering a path as a universal link via apple-app-site-association, I'm seeing that on pageloads on iOS safari, when I have the app installed, the system will inject an "open in app" banner on the top of the screen.

I'd like to disable this banner while preserving universal link support for this page. I don't see any official way to do this; is there any method, however hacky or unconventional, to accomplish this?

EDIT:

In my answer below, I realized that only loads when the app is not installed. What you are trying to accomplish may not be possible. Since the AASA file is installed on the device, Safari will automatically associate that web page with an app and therefore load the banner in the browser. I don't believe this is an HTML element that you can just remove with a JQuery call. A solution to this would be to use a redirecting link as your Universal Link. This way if the app is installed, the app will open, and if not then it will redirect to your site which isn't recognized as a Universal Link and will not show the banner. Branch is the a solid deep linking solution that uses redirects, so you won't have to deal with the Apple banner.

Removing banner when app is not installed

Make sure the smart app banner meta tag is not being loaded on your page. If you see this tag, take it out:

<meta name="apple-itunes-app" content="app-id=myAppStoreID, affiliate-data=myAffiliateData, app-argument=myURL">