Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Instance ID API cho phép bạn tích hợp Instance ID với ứng dụng Android hoặc iOS. Instance ID cung cấp một mã nhận dạng duy nhất cho từng phiên bản của ứng dụng và một cơ chế để xác thực và uỷ quyền các hành động. InstanceID có thời hạn sử dụng lâu dài, nhưng có thể hết hạn vì những lý do sau:
Đặt lại thiết bị về trạng thái ban đầu.
Người dùng gỡ cài đặt ứng dụng.
Người dùng thực hiện thao tác "Xoá dữ liệu" trong ứng dụng.
Thiết bị không được sử dụng trong một khoảng thời gian dài (thiết bị và khu vực sẽ xác định khoảng thời gian).
Dịch vụ mã nhận dạng phiên bản phát hiện hành vi sai trái hoặc lỗi và đặt lại InstanceID.
Mã phía máy chủ nếu ứng dụng khách của bạn yêu cầu chức năng đó.
Dịch vụ Instance ID sẽ thông báo cho ứng dụng của bạn về việc đặt lại InstanceID thông qua lệnh gọi lại đến một InstanceIDListenerService. Nếu nhận được thông báo này, ứng dụng của bạn phải gọi getToken() và truy xuất InstanceID mới, đồng thời cập nhật các máy chủ của ứng dụng.
Sử dụng phương thức getToken để chứng minh quyền sở hữu InstanceID và cho phép các máy chủ truy cập vào dữ liệu hoặc dịch vụ được liên kết với ứng dụng. Phương thức này tuân theo các mẫu của OAuth2 và yêu cầu authorizedEntity và scope. authorizedEntity có thể là mã dự án hoặc một InstanceID khác và mã này xác định những dịch vụ được phép sử dụng mã thông báo đã tạo. scope xác định dịch vụ hoặc dữ liệu cụ thể mà mã thông báo cho phép truy cập.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-09-10 UTC."],[[["\u003cp\u003eThe Instance ID API provides a unique identifier for each app instance and enables authentication and authorization.\u003c/p\u003e\n"],["\u003cp\u003eInstance IDs are long-lived but can expire due to various factors like device reset, uninstallation, data clearing, extended inactivity, or service-detected issues.\u003c/p\u003e\n"],["\u003cp\u003eUpon Instance ID reset, apps are notified and must retrieve a new ID using \u003ccode\u003egetToken()\u003c/code\u003e and update their servers.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003egetToken()\u003c/code\u003e method, using OAuth2 patterns, verifies Instance ID ownership and grants server access to associated data or services based on authorized entity and scope.\u003c/p\u003e\n"]]],[],null,["# Instance ID API\n\nThe Instance ID API lets you integrate Instance ID with your Android\nor iOS app. Instance ID provides a unique identifier for each instance of\nyour app and a mechanism to authenticate and authorize actions. The `InstanceID` is long\nlived, but may expire for the following reasons:\n\n- Device factory reset.\n- User uninstalls the app.\n- User performs \"Clear Data\" in the app.\n- Device unused for an extended period (device and region determines the timespan).\n- Instance ID service detects abuse or errors and resets the `InstanceID`.\n- Server-side code if your client app requires that functionality.\n\nThe Instance ID service notifies your app of an `InstanceID` reset via\ncallback to a `InstanceIDListenerService`. If your app receives this\nnotification, it must call `getToken()` and retrieve the new `InstanceID`,\nand update its servers.\n\nUse the `getToken` method to prove the ownership of the `InstanceID` and to allow\nservers to access data or services associated with the app. The method follows\nthe patterns of OAuth2, and requires an `authorizedEntity` and `scope`. The\n`authorizedEntity` can be a project ID or another `InstanceID`, and it determines\nthe services that are authorized to use the generated token. The `scope`\ndetermines the specific service or data to which the token allows access.\n\nLearn more about the Instance ID API for:\n\n[Android](/instance-id/reference/android/api)\n[iOS](/instance-id/reference/ios/api)\n[Server](/instance-id/reference/server)"]]