Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Funzionalità principali
Oltre a fornire ID univoci per l'autenticazione, l'ID istanza può generare token di sicurezza da utilizzare con altri servizi. Altre funzionalità:
Genera token di sicurezza
Instance ID fornisce un'API semplice per generare token di sicurezza che autorizzano terze parti ad accedere alle risorse gestite lato server della tua app.
Verificare l'autenticità dell'app
Passa i token ID istanza al tuo server e utilizza il servizio ID istanza per verificare il nome del pacchetto dell'app e controllare se ha una firma valida.
La verifica dei token con il servizio cloud Instance ID consente di identificare le app conosciute. Per ridurre i costi e le comunicazioni di andata e ritorno ridondanti, configura il
server in modo da memorizzare questi token in modo che il controllo sia necessario solo una volta.
In caso di problemi di sicurezza, l'app può eliminare i token o
l'ID istanza stessa e generarne di nuovi. Inoltre, il
server ID istanza avvia l'aggiornamento del token o dell'ID istanza se
rileva bug o problemi di sicurezza.
Verificare che il dispositivo dell'app sia attivo
Il server ID istanza può dirti quando è stato utilizzato l'ultimo dispositivo su cui è installata la tua app. Utilizzalo per decidere se conservare i dati della tua app o inviare un messaggio push per coinvolgere nuovamente gli utenti.
Identificare e monitorare le app
L'ID istanza è univoco per tutte le istanze di app in tutto il mondo, pertanto il tuo database può utilizzarlo per identificare e monitorare in modo univoco le istanze di app. Il codice lato server può verificare, tramite il servizio cloud Instance ID, che un ID istanza sia autentico e corrisponda all'ID dell'app originale registrata sul tuo server. Per motivi di privacy, la tua app può eliminare un ID istanza in modo che non sia più associato a nessuna cronologia nel database. La volta successiva che la tua app chiama l'ID istanza, riceverà un ID istanza completamente nuovo senza alcuna relazione con quello precedente.
Ciclo di vita dell'ID istanza
Il servizio ID istanza emette un InstanceID quando l'app viene messa online.
InstanceID è supportato da una coppia di chiavi pubblica/privata con la chiave privata memorizzata sul dispositivo locale e la chiave pubblica registrata con il servizio Instance ID.
L'app può richiedere un nuovo InstanceID ogni volta che è necessario utilizzando il metodo getID(). La tua app può archiviarli sul tuo server, se ne hai uno che supporta la tua app.
La tua app può richiedere token dal servizio Instance ID in base alle esigenze utilizzando il metodo getToken() e, come InstanceID, può anche archiviare i token sul tuo server. Tutti i token emessi per la tua app appartengono al
InstanceID dell'app.
I token sono univoci e sicuri, ma la tua app o il servizio Instance ID potrebbe doverli aggiornare in caso di problemi di sicurezza o quando un utente disinstalla e reinstalla la tua app durante il ripristino del dispositivo. L'app deve implementare un ascoltatore per rispondere alle richieste di aggiornamento dei token dal servizio ID istanza.
Implementazione del client
L'ID istanza funziona sia su Android che su iOS. Ognuno richiede di includere la libreria appropriata nell'app client. Android richiede Google Play Services. Se intendi generare token, devi disporre di un ID progetto generato da Google Developers Console.
Per istruzioni dettagliate, consulta le guide all'implementazione per Android
e iOS.
[null,null,["Ultimo aggiornamento 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."]]