インスタンス ID API
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Instance ID API を使用すると、Instance ID を Android アプリまたは iOS アプリに統合できます。Instance ID は、アプリの各インスタンスに一意の識別子と、アクションを認証して承認するメカニズムを提供します。InstanceID
は有効期間が長いですが、次の理由で期限切れになることがあります。
- デバイスを出荷時の設定にリセットします。
- ユーザーがアプリをアンインストールします。
- ユーザーがアプリで [データを消去] を実行した場合。
- デバイスが長期間使用されていない(デバイスと地域によって期間が異なります)。
- Instance ID サービスが不正使用またはエラーを検出し、
InstanceID
をリセットします。
- クライアント アプリでその機能が必要な場合のサーバーサイド コード。
Instance ID サービスは、InstanceIDListenerService
へのコールバックを介して、InstanceID
のリセットをアプリに通知します。アプリがこの通知を受け取った場合は、getToken()
を呼び出して新しい InstanceID
を取得し、サーバーを更新する必要があります。
getToken
メソッドを使用して InstanceID
の所有権を証明し、サーバーがアプリに関連付けられたデータやサービスにアクセスできるようにします。このメソッドは OAuth2 のパターンに従い、authorizedEntity
と scope
が必要です。authorizedEntity
はプロジェクト ID または別の InstanceID
にすることができ、生成されたトークンの使用が承認されるサービスを決定します。scope
は、トークンがアクセスを許可する特定のサービスまたはデータを決定します。
Instance ID API の詳細については、以下をご覧ください。
Android
iOS
サーバー
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-09-05 UTC。
[null,null,["最終更新日 2025-09-05 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)"]]