インスタンス ID は、認証用の一意の ID を提供できるだけでなく、他のサービスで使用するためのセキュリティ トークンを生成することもできます。その他の機能は次のとおりです。
セキュリティ トークンを生成する
インスタンス ID には、サードパーティがアプリのサーバーサイド管理リソースにアクセスすることを許可するセキュリティ トークンを生成するためのシンプルな API が用意されています。
アプリの真正性を確認する
インスタンス ID トークンをサーバーに渡し、インスタンス ID サービスを使用してアプリのパッケージ名を確認し、有効な署名があるかどうかを確認します。インスタンス ID Cloud サービスでトークンを検証すると、既知のアプリを特定できます。費用と冗長なラウンド トリップ通信を削減するには、これらのトークンを保存するようにサーバーを構成し、チェックが 1 回だけ必要になるようにします。セキュリティ上の懸念がある場合は、アプリでトークンまたはインスタンス ID 自体を削除して、新しいトークンを生成できます。また、Instance ID サーバーは、バグやセキュリティの問題を検出すると、トークンまたは Instance ID の更新を開始します。
アプリのデバイスが有効であることを確認する
Instance ID サーバーは、アプリがインストールされているデバイスが最後に使用された日時を把握できます。これを使用して、アプリのデータを保持するか、プッシュ メッセージを送信してユーザーとのエンゲージメントを再開するかを判断します。
アプリの特定と追跡
インスタンス ID は世界中のすべてのアプリ インスタンスで一意であるため、データベースで使用してアプリ インスタンスを一意に識別し、追跡できます。サーバーサイド コードは、インスタンス ID クラウド サービスを使用して、インスタンス ID が本物であり、サーバーに登録された元のアプリと同じ ID であることを検証できます。プライバシー保護のため、アプリはインスタンス ID を削除して、データベース内の履歴に関連付けられなくすることができます。アプリが次回 Instance ID を呼び出すと、以前の Instance ID とは関係のないまったく新しい Instance ID が取得されます。
インスタンス ID のライフサイクル
アプリがオンラインになると、Instance ID サービスが InstanceID を発行します。InstanceID は、ローカル デバイスに保存された秘密鍵と、Instance ID サービスに登録された公開鍵を持つ公開/秘密鍵ペアによってサポートされています。
アプリは、必要に応じて getToken() メソッドを使用して Instance ID サービスからトークンをリクエストできます。また、InstanceID と同様に、アプリは独自のサーバーにトークンを保存することもできます。アプリに発行されるすべてのトークンは、アプリの InstanceID に属します。
トークンは一意で安全ですが、セキュリティの問題が発生した場合や、ユーザーがデバイスの復元中にアプリをアンインストールして再インストールした場合は、アプリまたは Instance ID サービスでトークンを更新する必要があります。アプリは、Instance ID サービスからのトークン更新リクエストに応答するリスナーを実装する必要があります。
[null,null,["最終更新日 2025-08-31 UTC。"],[[["\u003cp\u003e\u003cstrong\u003eWarning:\u003c/strong\u003e The Instance ID API is deprecated; for unique app installation identifiers, use the Firebase installations API instead.\u003c/p\u003e\n"],["\u003cp\u003eInstance ID offers key features like generating security tokens, verifying app authenticity, confirming app device activity, and identifying/tracking apps.\u003c/p\u003e\n"],["\u003cp\u003eInstance ID has a lifecycle involving issuing an ID, requesting fresh IDs and tokens, storing them on the server (optional), and handling token refreshes.\u003c/p\u003e\n"],["\u003cp\u003eClient implementation requires including the appropriate library and potentially a Project ID for token generation.\u003c/p\u003e\n"],["\u003cp\u003eFor detailed instructions, refer to the Android and iOS implementation guides.\u003c/p\u003e\n"]]],[],null,["# What is Instance ID?\n\n| **Warning:** The Instance ID API is deprecated. If you need to access unique app installation identifiers, use the [Firebase installations](//firebase.google.com/docs/projects/manage-installations) API. See also [Firebase installations and Instance ID](//firebase.google.com/docs/projects/manage-installations#fid-iid). The [server-side topic management API](https://developers.google.com/instance-id/reference/server#create_relationship_maps_for_app_instances) is still available.\n\nKey features\n------------\n\nIn addition to providing unique IDs for authentication, Instance ID\ncan generate security tokens for use with other services. Other features\ninclude:\n\n### Generate Security Tokens\n\n: Instance ID provides a simple API to generate security tokens that\n authorize third parties to access your app's server side managed resources.\n\n### Verify app authenticity\n\n: Pass Instance ID tokens to your server and use the Instance ID\n service to verify the app package name and check if it has a valid signature.\n Verifying tokens with the Instance ID Cloud Service helps identify known\n apps. To reduce cost and redundant round trip communications, configure your\n server to store these tokens so the check is needed only once.\n In the event of a security concern, your app can delete tokens, or\n Instance ID itself, and generate new ones. In addition, the\n Instance ID server initiates token or Instance ID refresh if it\n detects bugs or security issues.\n\n### Confirm app device is active\n\n: The Instance ID server can tell you when the device on which your app\n is installed was last used. Use this to decide whether to keep data from your\n app or send a push message to reengage with your users.\n\n### Identify and track apps\n\n: Instance ID is unique across all app instances across the world, so\n your database can use it to uniquely identify and track app instances. Your\n server-side code can verify, via the Instance ID cloud service, that an\n Instance ID is genuine and is the same ID as the original app that\n registered with your server. For privacy, your app can delete an Instance ID so\n it is no longer associated with any history in the database. The next time your\n app calls Instance ID it will get an entirely new Instance ID with no\n relationship to its previous one.\n\nInstance ID lifecycle\n---------------------\n\n1. The Instance ID service issues an `InstanceID` when your app comes online. The `InstanceID` is backed by a public/private key pair with the private key stored on the local device and the public key registered with the Instance ID service.\n2. Your app can request a fresh `InstanceID` whenever needed using the `getID()` method. Your app can store it on your server if you have one that supports your app.\n3. Your app can request tokens from the Instance ID service as needed using the `getToken()` method, and like `InstanceID`, your app can also store tokens on your own server. All tokens issued to your app belong to the app's `InstanceID`.\n4. Tokens are unique and secure, but your app or the Instance ID service may need to refresh tokens in the event of a security issue or when a user uninstalls and reinstalls your app during device restoration. Your app must implement a listener to respond to token refresh requests from the Instance ID service.\n\nClient implementation\n---------------------\n\nInstance ID runs on both Android and iOS. Each requires you to include\nthe appropriate library in your client app. Android requires\n[Google Play Services](https://developer.android.com/google/play-services/index.html). You will need a Project ID generated\nby the [](/console/help/new)[Google Developers Console](https://console.developers.google.com/project) if you intend\nto generate tokens.\n\nFor detailed instructions, see the [Android](/instance-id/guides/android-implementation)\nand [iOS](/instance-id/guides/ios-implementation) implementation guides."]]