You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

iOS Universal Links配置:排除裸域名,仅带路径链接唤起应用

Absolutely, this is totally doable with iOS Universal Links! Let me walk you through exactly how to configure everything to match your needs:

1. Configure the apple-app-site-association File

This is the backbone of Universal Links. You'll need to define path rules that exclude the root domain but include all other paths. Here's what the file should look like:

{
  "applinks": {
    "apps": [],
    "details": [
      {
        "appID": "YOUR_TEAM_ID.YOUR_BUNDLE_ID",
        "paths": [ "NOT /", "/*" ]
      }
    ]
  }
}
  • NOT /: This rule tells iOS that the root URL (mydomain.com/) should not trigger your app—so it'll always open in Safari instead.
  • /*: This catches all other paths (like mydomain.com/sometext, mydomain.com/anotherpath, etc.) and tells iOS to attempt to open your app if it's installed.

2. iOS App Configuration

  • Open your Xcode project, go to your target's Signing & Capabilities tab.
  • Add the Associated Domains capability, then add a domain entry in the format: applinks:mydomain.com (replace with your actual domain).
  • Double-check that your Team ID and Bundle ID in the apple-app-site-association file match exactly what's in Xcode.

3. Web Server & Fallback Handling

  • Host the apple-app-site-association file at either https://mydomain.com/apple-app-site-association or https://mydomain.com/.well-known/apple-app-site-association. Make sure the file has no file extension and that your server returns it with a Content-Type: application/json header.
  • For paths that should open the app (if installed), set up a fallback on your web server: if iOS doesn't launch the app (meaning it's not installed), the link should load the corresponding web page content instead. Most server-side frameworks or static site hosts let you handle this easily.

Quick Testing Tips

  • Test on a real iOS device (simulators can have inconsistent Universal Links behavior).
  • Avoid tapping links directly in Messages or Mail during initial testing—use a Notes app link or a web page link instead, since some apps override link handling.
  • You can use Apple's built-in validation tool to verify your apple-app-site-association file is set up correctly.

内容的提问来源于stack exchange,提问作者Baldoph

火山引擎 最新活动