Push Devices

Once your app has enabled the push notifications, you can use the APIs to register user devices such as iPhones and Android phones.

Each chat user has a limit of 25 unique devices. Once this limit is reached, the oldest device will be removed and replaced by the new device.

Device Parameters

nametypedescriptiondefaultoptional
user_idstringThe user ID for this device-
idstringThe device ID.-
push_providerstringThe push provider for this device. Either APN, Firebase, Huawei, or Xiaomi.-
disabledbooleanSet if the device is disabled-
disabled_reasonstringExplanation if the device is disabled-
push_provider_namestringThe push provider name for this device if a multi-bundle configuration is added.-

Register a Device

Registering a device associates it with a user and tells the push provider to send new message notifications to the device.

Register the user’s device for remote push notifications once your user is successfully connected to Chat.

Multi-bundle configurations require that you specify a push_provider_name when registering a device that corresponds to the name of the push configuration that you’ve set up in the dashboard or via the API.

await Client.DeviceApi.AddDeviceAsync(new CreateDeviceRequest
{
  //Device ID provided by the notifications provider e.g. Token provided by Firebase Messaging SDK
  Id = "unique-device-id", 
  PushProvider = PushProviderType.Firebase,
});

Unregister a Device

Unregistering a device removes the device from the user and stops further new message notifications.

await Client.DeviceApi.RemoveDeviceAsync(deviceId, Client.UserId);

List Devices

Provides a list of all devices associated with a user.

var response = await Client.DeviceApi.ListDevicesAsync(Client.UserId);
foreach (var userDevice in response.Devices)
{
  Debug.Log(userDevice.Id); // Unique Device ID provided by push notifications provider
  Debug.Log(userDevice.CreatedAt);
  Debug.Log(userDevice.PushProvider); //E.g. Firebase
  Debug.Log(userDevice.Disabled);
  Debug.Log(userDevice.DisabledReason);
}
© Getstream.io, Inc. All Rights Reserved.