เริ่มต้นใช้งาน
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ภาพรวม
โปรโตคอลลิงก์เนื้อหาดิจิทัล (Digital Asset Links) และ API จะช่วยให้แอปหรือเว็บไซต์เผยแพร่ข้อความเกี่ยวกับแอปหรือเว็บไซต์อื่นๆ แบบสาธารณะและยืนยันได้ เช่น เว็บไซต์อาจประกาศว่าเชื่อมโยงกับแอป Android ที่เจาะจง หรือประกาศว่าต้องการแชร์ข้อมูลเข้าสู่ระบบของผู้ใช้กับเว็บไซต์อื่น
ตัวอย่างการใช้งานลิงก์เนื้อหาดิจิทัล (Digital Asset Links) ต่อไปนี้
- เว็บไซต์ ก ประกาศว่าลิงก์ไปยังเว็บไซต์ควรเปิดในแอปที่กำหนดบนอุปกรณ์เคลื่อนที่ (หากติดตั้งแอปไว้)
- เว็บไซต์ ก ประกาศว่าสามารถแชร์ข้อมูลเข้าสู่ระบบของผู้ใช้ Chrome กับเว็บไซต์ ข เพื่อให้ผู้ใช้ไม่ต้องเข้าสู่ระบบเว็บไซต์ ข หากเข้าสู่ระบบเว็บไซต์ ก
- แอป ก ประกาศว่าสามารถแชร์การตั้งค่าอุปกรณ์ เช่น ตำแหน่ง กับเว็บไซต์ ข ได้
คำสำคัญ
- ผู้ใช้หลัก: ผู้ใช้หลักคือแอปหรือเว็บไซต์ที่แถลงข้อความ ในลิงก์เนื้อหาดิจิทัล ผู้ใช้หลักจะเป็นแอปหรือเว็บไซต์ที่โฮสต์รายการใบแจ้งยอดเสมอ
- รายการใบแจ้งยอด: คำสั่งจะอยู่ในรายการคำสั่งที่มีคำสั่งอย่างน้อย 1 รายการ รายการข้อความเป็นข้อความที่ชัดเจนและเข้าถึงได้แบบสาธารณะ ในสถานที่ที่มีการควบคุมโดยครูใหญ่และปลอมแปลงหรือดัดแปลงได้ยาก
ซึ่งอาจเป็นไฟล์แบบลอยตัวหรือส่วนหนึ่งของไฟล์อื่นที่มีขนาดใหญ่กว่า เช่น ในเว็บไซต์จะเป็นทั้งไฟล์ แต่ในแอป Android จะอยู่ในส่วนในไฟล์ Manifest ของแอป
ทุกคนสามารถดูและยืนยันใบแจ้งยอดได้ โดยใช้วิธีการที่ไม่ใช่กรรมสิทธิ์ ดูข้อมูลเพิ่มเติมในเอกสารรายการใบแจ้งยอด
- คำสั่ง: คำสั่งคือโครงสร้าง JSON ที่มีโครงสร้างแบบกระชับซึ่งประกอบด้วยrelation (สิ่งที่คำสั่งระบุไว้ว่าต้องทำ เช่น เปิดใช้ข้อมูลเข้าสู่ระบบการแชร์) และrelation (เว็บไซต์หรือแอปที่เกี่ยวข้องด้วย) ดังนั้น แต่ละข้อความจึงมีลักษณะเหมือนประโยคที่ ผู้หลัก เขียนคำว่า relation เกี่ยวกับ target
- ผู้บริโภคที่ใช้ใบแจ้งยอด: ผู้บริโภคตามใบแจ้งยอดจะขอรายการใบแจ้งยอดจากผู้ใช้หลัก ตรวจสอบว่ามีข้อความใดเกี่ยวกับผู้ใช้หลักรายหนึ่งๆ หรือไม่ และดำเนินการตามที่ระบุไว้ได้ หากมี ดูข้อมูลเพิ่มเติมในคำชี้แจงเกี่ยวกับเอกสารประกอบ.
ตัวอย่างการใช้งานอย่างรวดเร็ว
ต่อไปนี้เป็นตัวอย่างง่ายๆ เกี่ยวกับวิธีที่เว็บไซต์ www.example.com ใช้ลิงก์เนื้อหาดิจิทัลเพื่อระบุว่าลิงก์ไปยัง URL ในเว็บไซต์นั้นควรเปิดในแอปที่กำหนดแทนการเปิดในเบราว์เซอร์
- เว็บไซต์ www.example.com เผยแพร่รายการคำสั่งที่ https://www.example.com/.well-known/assetlinks.json ชื่อนี้เป็นชื่อทางการและสถานที่ตั้งของรายการใบแจ้งยอดในเว็บไซต์ รายการใบแจ้งยอดในตำแหน่งอื่นๆ หรือชื่ออื่นๆ จะใช้กับเว็บไซต์นี้ไม่ได้ ในตัวอย่างของเรา รายการคำสั่งประกอบด้วยคำสั่งเดียว ซึ่งให้สิทธิ์แอป Android เปิดลิงก์ในเว็บไซต์ ดังนี้
[{
"relation": ["delegate_permission/common.handle_all_urls"],
"target" : { "namespace": "android_app", "package_name": "com.example.app",
"sha256_cert_fingerprints": ["hash_of_app_certificate"] }
}]
รายการคำสั่งรองรับอาร์เรย์ของคำสั่งภายในเครื่องหมาย [ ] แต่ไฟล์ตัวอย่างของเรามีเพียงคำสั่งเดียว
sha256_cert_fingerprints
คือลายนิ้วมือ SHA256 ของใบรับรองที่ลงนามของแอป
ดูรายละเอียดเพิ่มเติมในเอกสารประกอบเกี่ยวกับ Android App Link
- แอป Android ที่แสดงในคำสั่งด้านบนมีตัวกรอง Intent ที่ระบุรูปแบบ โฮสต์ และรูปแบบเส้นทางของ URL ที่ต้องการจัดการ ในกรณีนี้คือ https://www.example.com ตัวกรอง Intent
มีแอตทริบิวต์พิเศษ
android:autoVerify
ซึ่งเป็นแอตทริบิวต์ใหม่ที่เป็น
Android M ซึ่งบ่งชี้ว่า Android ควรยืนยันคำสั่ง
ในเว็บไซต์ที่อธิบายไว้ในตัวกรอง Intent เมื่อติดตั้งแอป
- ผู้ใช้ติดตั้งแอป Android จะเห็นตัวกรอง Intent ที่มีแอตทริบิวต์
autoVerify
และตรวจสอบว่ามีรายการคำสั่งในเว็บไซต์ที่ระบุหรือไม่ หากมี Android จะตรวจสอบว่าไฟล์ดังกล่าวมีคำสั่งที่ให้สิทธิ์จัดการลิงก์กับแอปหรือไม่ และยืนยันแอปกับคำสั่งตามแฮชใบรับรอง หากทุกอย่างได้รับการตรวจสอบ Android จะส่งต่อ https://www.example.com Intent ใดๆ ไปยังแอป example.com
- ผู้ใช้คลิกลิงก์ไปยัง https://www.example.com/puppie บนอุปกรณ์ของตน ลิงก์นี้อาจเป็นที่ใดก็ได้ ไม่ว่าจะเป็นในเบราว์เซอร์ ในคำแนะนำของ Google Search Appliance หรือที่อื่นๆ Android
ส่งต่อ Intent ไปยังแอป example.com
- แอป example.com ได้รับ Intent และเลือกที่จะจัดการ
โดยเปิดหน้าเกี่ยวกับลูกสุนัขในแอป หากแอปปฏิเสธที่จะจัดการลิงก์ด้วยเหตุผลบางประการ หรือในกรณีที่แอปไม่ได้อยู่ในอุปกรณ์
ระบบจะส่งลิงก์ไปที่เครื่องจัดการความตั้งใจเริ่มต้นถัดไปที่ตรงกับรูปแบบ Intent นั้น (มักจะเป็นเบราว์เซอร์)
ข้อควรพิจารณาและข้อจำกัดที่สำคัญ
- โปรโตคอลไม่ได้ตรวจสอบสิทธิ์ผู้ใช้หลักที่เป็นผู้รายงาน แต่ข้อความดังกล่าวอยู่ในตำแหน่งที่ตั้งเฉพาะที่เกี่ยวข้องกับผู้ใช้หลักอย่างยิ่ง และอยู่ภายใต้การควบคุมของผู้หลัก
- โปรโตคอลไม่ได้ตรวจสอบสิทธิ์เป้าหมายของคำสั่ง แต่จะระบุวิธีการให้ผู้โทรตรวจสอบสิทธิ์เป้าหมาย (เช่น คำสั่งระบุเป้าหมายแอปบนอุปกรณ์เคลื่อนที่ตามแฮชใบรับรองและชื่อแพ็กเกจ)
- โปรโตคอลไม่ได้ดำเนินการใดๆ กับข้อความตั้งแต่ต้น แต่จะช่วยให้แสดงคำสั่งได้ ซึ่งแอปพลิเคชันที่ใช้งานจะต้องตรวจสอบความถูกต้อง จากนั้นตัดสินใจว่าจะดำเนินการอย่างไรและต่อไปอย่างไร Android M จะดำเนินการขั้นตอนเหล่านี้ให้คุณตั้งแต่แรก
ตัวอย่างเช่น หากเว็บไซต์มอบสิทธิ์ในการจัดการลิงก์ให้กับแอปใดแอปหนึ่ง Android จะตรวจสอบและยืนยันคำสั่ง ยืนยันแอปเป้าหมาย
จากนั้นจึงเสนอตัวเลือกให้แอปจัดการลิงก์ดังกล่าว
- โปรโตคอลไม่อนุญาตให้ระบุข้อมูลเกี่ยวกับบุคคลที่สาม 2 ราย กล่าวคือ เว็บไซต์ ก. สามารถกล่าวถึงเว็บไซต์ ข.
แต่เว็บไซต์ ก. แสดงความคิดเห็นเกี่ยวกับความสัมพันธ์ของเว็บไซต์ ข.
กับเว็บไซต์ ค ไม่ได้ อย่างไรก็ตาม หากเว็บไซต์ ข เชื่อถือเว็บไซต์ ก ก็จะตรวจสอบเว็บไซต์ ก เพื่อดูคำชี้แจงที่ให้สิทธิ์แก่เว็บไซต์ ค และตัดสินใจนำเว็บไซต์นั้นไปใช้
ขั้นตอนถัดไป
- ดูว่ามีเอกสารประกอบที่ชัดเจนสำหรับกรณีการใช้งานของคุณหรือไม่
- ดูข้อมูลเกี่ยวกับการสร้างคำสั่ง
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2024-06-26 UTC
[null,null,["อัปเดตล่าสุด 2024-06-26 UTC"],[[["\u003cp\u003eDigital Asset Links enable apps and websites to make verifiable statements about their relationships with other apps and websites, such as link handling or credential sharing.\u003c/p\u003e\n"],["\u003cp\u003eThese statements are stored in a publicly accessible statement list, typically an "assetlinks.json" file hosted by the app or website making the statement.\u003c/p\u003e\n"],["\u003cp\u003eAndroid M and above automatically uses Digital Asset Links to verify website-to-app associations and direct links to the appropriate app if installed.\u003c/p\u003e\n"],["\u003cp\u003eThe protocol provides a foundation for trust and delegation between digital entities but relies on consumers to validate and act upon the statements.\u003c/p\u003e\n"]]],[],null,["# Getting Started\n\nOverview\n--------\n\nThe Digital Asset Links protocol and API enable an app or website to make public,\nverifiable *statements* about other apps or websites. For example, a website\ncan declare that it is associated with a specific Android app, or it can declare that\nit wants to share user credentials with another website.\n\nHere are some possible uses for Digital Asset Links:\n\n- Website A declares that links to its site should open in a designated app on mobile devices, if the app is installed.\n- Website A declares that it can share its Chrome user credentials with website B so that the user won't have to log in to website B if it is logged into website A.\n- App A declares that it can share device settings, such as location, with website B.\n\n### Key terms\n\n- **Principal:** The principal is the app or website making the statement. In Digital Asset Links, the principal is always the app or website that hosts the statement list.\n- **Statement list** : Statements are contained in a *statement list* that contains one or more statements. A statement list is cleartext and publicly accessible, in a location that is controlled by the principal and difficult to spoof or tamper with. It can be a free-standing file, or a section of another, larger item. For example, on a website, it is an entire file; in an Android app, it is a section in the app manifest. Statements can be viewed and verified by anyone, using non-proprietary methods. [See the statement list documentation for more information](/digital-asset-links/v1/create-statement).\n- **Statement:** A statement is a tightly structured JSON construct that consists of a *relation* (what the statement says to do, for example: Enable sharing credentials) and a *target* (the website or app that the relation applies to). Therefore, each statement is like a sentence, where *principal* says *relation* about *target* . \n- **Statement consumer:** A statement consumer requests a statement list from a principal, checks for the presence of a statement against a given principal, and if it exists, can perform the action specified. [See the statement comsuming documentation for more information](/digital-asset-links/v1/consuming)*.*\n\nQuick usage example\n-------------------\n\nHere's a very simplified example of how the website www.example.com could\nuse Digital Asset Links to specify that any links to URLs in that site should\nopen in a designated app rather than the browser:\n\n1. The website www.example.com publishes a statement list at https://www.example.com/.well-known/assetlinks.json. This is the official name and location for a statement list on a site; statement lists in any other location, or with any other name, are not valid for this site. In our example, the statement list consists of one statement, granting its Android app the permission to open links on its site: \n\n ```\n [{\n \"relation\": [\"delegate_permission/common.handle_all_urls\"],\n \"target\" : { \"namespace\": \"android_app\", \"package_name\": \"com.example.app\",\n \"sha256_cert_fingerprints\": [\"hash_of_app_certificate\"] }\n }]\n ```\n A statement list supports an array of statements within the \\[ \\] marks, but our example file contains only one statement. `sha256_cert_fingerprints` is the SHA256 fingerprints of your app's signing certificate. Find more details in the [Android App Links documentation](https://developer.android.com/training/app-links/verify-android-applinks#web-assoc).\n2. The Android app listed in the statement above has an intent filter that specifies the scheme, host, and path pattern of URLs that it wants to handle: in this case, https://www.example.com. The intent filter includes a special attribute `android:autoVerify`, new to Android M, which indicates that Android should verify the statement on the website described in the intent filter when the app is installed.\n3. A user installs the app. Android sees the intent filter with the `autoVerify` attribute and checks for the presence of the statement list at the specified site; if present, Android checks whether that file includes a statement granting link handling to the app, and verifies the app against the statement by certificate hash. If everything checks out, Android will then forward any https://www.example.com intents to the example.com app.\n4. The user clicks a link to https://www.example.com/puppies on their device. This link could be anywhere: in a browser, in a Google Search Appliance suggestion, or anywhere else. Android forwards the intent to the example.com app.\n5. The example.com app receives the intent and chooses to handle it, opening the puppies page in the app. If for some reason the app had declined to handle the link, or if the app were not on the device, then the link would have been sent to the next default intent handler matching that intent pattern (often the browser).\n\nImportant considerations and limitations:\n-----------------------------------------\n\n- The protocol does not authenticate the principal making the statement, but the statement is located in a specific location strongly associated with the principal, and under control of the principal.\n- The protocol does not authenticate the statement target, but it provides a means for the caller to authenticate the target (for example, a statement identifies mobile app targets by certificate hash and package name).\n- The protocol does not natively perform any statement actions; rather, it enables the ability to expose statements, which a consuming application must validate and then decide whether and how to act upon. Android M natively performs these steps for you; for example, if a website delegates link handling to a specific app, Android checks and verifies the statement, verifies the target app, and then offers the app the option to handle the given link.\n- The protocol does not enable making statements about two third parties: that is, website A can make a statement about website B, but website A cannot make a statement about website B's relationship to website C. However, if website B trusts website A, it can check website A for a statement granting permission to website C, and decide to implement that.\n\nNext steps\n----------\n\n1. [See if there is explicit documentation for your use case.](/digital-asset-links/v1/using)\n2. [Learn about creating a statement.](/digital-asset-links/v1/create-statement)"]]