[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2024-06-26 (世界標準時間)。"],[[["\u003cp\u003eDigital Asset Links rely on JSON-encoded statement lists hosted in a well-known location on a website or within an Android app's strings.xml file.\u003c/p\u003e\n"],["\u003cp\u003eWebsite statement lists reside in a file named \u003ccode\u003eassetlinks.json\u003c/code\u003e within the \u003ccode\u003e.well-known\u003c/code\u003e directory, accessible via the website's domain.\u003c/p\u003e\n"],["\u003cp\u003eAndroid app statement lists are stored as a JSON string resource and referenced in the app's manifest using the \u003ccode\u003easset_statements\u003c/code\u003e metadata.\u003c/p\u003e\n"],["\u003cp\u003eStatement targets must be carefully matched against real-world entities, requiring precise scheme, host, and port matching for websites and exact package name and certificate hash matching for Android apps.\u003c/p\u003e\n"]]],[],null,["# Creating a Statement List\n\nStatements are hosted in a JSON-encoded statement list in a well-known\nlocation on a principal, as defined by the [Asset\nLinks Specification](https://github.com/google/digitalassetlinks/blob/master/well-known/details.md). A statement list contains one or more statements, and\na principal can have only one statement list.\n\nStatement list syntax\n---------------------\n\nSee the [statement list syntax](/digital-asset-links/v1/statements).\n\nStatement list location\n-----------------------\n\nThe statement list is hosted in a well known location that depends on the type of *principal* (the website or app making the statements).\n\n### Website statement lists\n\nOn a website, a statement list is a text file located at the following address:\n\n\u003cvar translate=\"no\"\u003escheme\u003c/var\u003e://\u003cvar translate=\"no\"\u003edomain\u003c/var\u003e/.well-known/assetlinks.json\n\nNote the dot in the .well-known folder name.\n\nAny response from the server besides `HTTP 200` is treated as an error, and will result in\nan empty statement list. For HTTPS, any connection without a certificate chain that\ncan be verified with the trusted root list will also result in an empty statement list.\n| The assetlinks.json file must be served as `Content-Type: application/json` in the HTTP headers, and it cannot be a redirect (that is, `301` or `302` response codes are not followed).\n\n**Example**\n\nHere is an example statement list on a website: \u003chttp://example.digitalassetlinks.org/.well-known/assetlinks.json\u003e\n\n### Android app statement lists\n\nIn an Android app, the statement list is a JSON snippet with the same syntax as a website statement file, but it is embedded in the strings.xml file, and referenced in the manifest as shown next.\n\n#### **In AndroidManifest.xml:**\n\n```\n\u003cmanifest\u003e\n \u003capplication\u003e\n ...\n \u003cmeta-data android:name=\"asset_statements\" android:resource=\"@string/asset_statements\" /\u003e\n ...\n \u003c/application\u003e\n\u003c/manifest\u003e\n```\n\n#### **In res/values/strings.xml:**\n\n```\n\u003cresources\u003e\n ...\n \u003cstring name=\"asset_statements\"\u003e\n ... /digital-asset-links/v1/statements ...\n \u003c/string\u003e\n\u003c/resources\u003e\n```\n\n**Example**\n\nHere is an example res/values/strings.xml snippet for an Android app that supports location sharing with the app (an Android feature not currently supported): \n\n```scdoc\n\u003cresources\u003e\n ...\n \u003cstring name=\"asset_statements\"\u003e\n [{\n \\\"relation\\\": [\\\"delegate_permission/common.share_location\\\"],\n \\\"target\\\": {\n \\\"namespace\\\": \\\"web\\\",\n \\\"site\\\": \\\"https://example.com\\\"\n }\n }]\n \u003c/string\u003e\n\u003c/resources\u003e\n```\n\nMatching a target\n-----------------\n\nEvery statement is about a *target*. When you consume a statement, you must match the target in a statement against some entity in reality. If the statement target matches the entity, the statement applies. Here are the rules for determining if a target matches a given entity:\n\n### **Website targets**\n\nFor a website, the site scheme, host, and port must match exactly. Default ports for HTTP and HTTPS (80 and 443 respectively) are assumed implicitly; if a statement target describes http://www.example.com:80, then the website http://www.example.com is considered a match.\n\n**Example**\n\nGiven the following statement target \n\n```\n\"target\": {\n \"namespace\": \"web\",\n \"site\": \"https://www.google.com\"\n}\n```\n\nThe following URIs **WILL**match:\n\n- https://www.google.com/\n- https://www.google.com:443/\n- https://www.google.com/foo\n- https://www.google.com/foo?bar\n- https://www.google.com/foo#bar\n- https://user@password:www.google.com/\n\nThe following URLs **will NOT** match:\n\n- http://www.google.com/ (*Wrong scheme*)\n- https://google.com/ (*Host name does not match*)\n- https://www.google.com:444/ (*Port does not match*)\n\n### App targets\n\nFor an app, the certificate hash and package name of the target must exactly match the application."]]