> [!WARNING]
> **Warning:** **The Instance ID API is deprecated.** If you need to access unique app installation identifiers, use the [Firebase installations](https://firebase.google.com/docs/projects/manage-installations.md.txt) API. See also [Firebase installations and Instance ID](https://firebase.google.com/docs/projects/manage-installations.md.txt#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.

Instance IDs identify individual installations of your app. Since each Instance
ID is unique to a particular app and device, they give Firebase services a way
to refer to specific app instances. For example, Cloud Messaging uses
Instance IDs to determine which devices to send messages to.

Several Firebase services use Instance IDs to power their features:

- Analytics
- Crashlytics
- Cloud Messaging
- Remote Config

## Manage app data associated with Instance IDs

Services that use Instance IDs to identify installations also use them as a key to
associate relevant data with that device. For example, Crashlytics uses
Instance IDs to record crashes that happen on the device, Remote Config uses
them to fetch configurations, and Analytics uses Instance IDs to track
particular audiences.

Data associated with Instance IDs is generally *not* personally-identifying,
but it can still be helpful to give users an option to manage it. To that
end, Firebase offers two ways to manage Instance-ID-related data collection:

- **Delete Instance IDs.** You can delete an Instance ID with a server- or client-side API call. Deleting an Instance ID deletes the ID itself and all data associated with it.
- **Disable services that generate IDs.** Most Firebase services that use Instance IDs automatically generate a new ID if there isn't one on the device when they start up. To ensure your app doesn't create unwanted Instance IDs, disable auto-initialization for those services.

## Delete an Instance ID

Deleting an Instance ID also deletes data associated with that ID in any of the
Firebase services listed above. That makes ID deletion a helpful tool in
clearing user data, but also comes with a caveat: if you're using multiple
services that rely on Instance IDs, deleting an ID clears data from *all* of
them.

The Instance ID service creates a new ID within a few days, unless you
disable all Instance-ID-generating services in your app. Firebase considers the
newly-created ID to be a brand new app instance, and doesn't associate it with
the previous ID in any way.

> [!NOTE]
> **Note:** Google Analytics uses its own form of Instance ID to keep track of analytics data. Deleting a regular Instance ID does *not* delete Analytics data. Learn how to [delete Analytics data associated with end users](https://support.google.com/firebase/answer/9019185#delete-on-mobile-device).

### Delete an ID with a client API call

To delete IDs generated by Firebase services, call the appropriate method from
the Firebase Instance ID API:

### Swift

```swift
InstanceID.instanceID().deleteID { error in
  if let error = error {
    print("Error deleting instance ID: \(error)")
  }
}
```

### Objective-C

```objective-c
[FIRInstanceID instanceID] deleteIDWithHandler:^(NSError *error) {
  if error != nil {
    NSLog(@"Error deleting instance ID: %@", error);
  }
}];
```

### Android

    FirebaseInstanceId.deleteInstanceId();

### Delete an ID with a server API call

To delete an Instance ID with server API calls, [add the Firebase Admin SDK to your server](https://firebase.google.com/docs/admin/setup.md.txt),
if you haven't already.

Once it's added, delete IDs through a call to the Instance ID deletion function
in your language of choice:

### Node.js

```javascript
// An Instance ID sent from a client service SDK
const idToDelete = 'INSTANCE_ID';

admin.instanceId().deleteInstanceId(idToDelete);
```

### Java

```java
// An Instance ID sent from a client service SDK
String idToDelete = "INSTANCE_ID";

FirebaseInstanceId.getInstance().deleteInstanceIdAsync(idToDelete).get();
```

### Python

```python
  from firebase_admin import instance_id

  # An Instance ID sent from a client service SDK
  id_to_delete = 'INSTANCE_ID'

  instance_id.delete_instance_id(id_to_delete)
```

### Go

```go
client, err := app.InstanceId(ctx)
if err != nil {
  log.Fatalln("error initializing client", err)
}

iidToDelete := "INSTANCE_ID"
if err := client.DeleteInstanceId(ctx, iidToDelete); err != nil {
  log.Fatalln("error deleting iid", err)
}
```

When you delete an Instance ID with a server API call, Firebase services delete
the associated data, stop accepting new data for that ID, and, within a few days,
notify the client app that the ID was deleted. Until Firebase notifies the client
app, some of the app's services might experience reduced functionality.

If you want to delete the current Instance ID and immediately use Firebase
services with a new, independent ID, use one of the Client APIs above to
handle the deletion.

## Disable Instance ID generation

Services that use Instance IDs automatically generate a new ID when they're
initialized in an app that doesn't currently have one. Typically, those services
also automatically initialize when your app launches. To disable Instance
ID generation, you have to disable auto-initialization for services that use
them.

A common approach is to give users an option to
opt-in to data collection: disable auto-initialization for
the services that use Instance IDs, implement a dialog that prompts
users for their consent to data collection, and re-enable the services manually
once you have consent.

Read the guides below to find out how to disable auto-initialization for
Instance-ID-using services and instead manually initialize them:

- Cloud Messaging: [Prevent Auto-initialization (Android)](https://firebase.google.com/docs/cloud-messaging/android/client#prevent-auto-init) or [Prevent Auto-initialization (iOS+)](https://firebase.google.com/docs/cloud-messaging/ios/client#prevent_auto_initialization)
- Crash Reporting: [Enable Opt-in Reporting](https://firebase.google.com/docs/crash/disable-sdk)
- Analytics: [Configure Analytics Data Collection](https://firebase.google.com/docs/analytics/configure-data-collection)

> [!NOTE]
> **Note:** Firebase Remote Config also generates Instance IDs, but isn't automatically initialized on app start. To delay ID generation in Remote Config, don't use the service until you're ready to generate an ID.