Devices

Last Edit: Feb 02 2020

Once your app has push enabled, 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

Name Type Description Default Optional
user_id string The user ID for this device -
id string The device ID. -
provider string The push provider for this device. Either APN or firebase. -

Register a Device


await client.addDevice(
    '2ffca4ad6599adc9b5202d15a5286d33c19547d472cd09de44219cda5ac30207', 
    'apn', 
    '42'
)
                    

client.add_device(
    '2ffca4ad6599adc9b5202d15a5286d33c19547d472cd09de44219cda5ac30207', 
    'apn', 
    '42'
)
                    

client.add_device(
    '2ffca4ad6599adc9b5202d15a5286d33c19547d472cd09de44219cda5ac30207', 
    'apn', 
    '42'
)
                    

client.addDevice(deviceToken, new CompletableCallback() { ... });
                    

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    Client.shared.addDevice(deviceToken: deviceToken).subscribe().disposed(by: disposeBag)
}
                    

stream chat:push:device:add \
    --device_id '2ffca4ad6599adc9b5202d15a5286d33c19547d472cd09de44219cda5ac30207'
    --user_id '42'
    --provider 'apn'
                    

$add = $client->addDevice(
    '2ffca4ad6599adc9b5202d15a5286d33c19547d472cd09de44219cda5ac30207', 
    'apn', 
    'elon'
);
                    

// register the device with APN (Apple only)
await client.addDevice("device-token", "apn");
        
// register the device with Firebase (Android only)
await client.addDevice("device-token", "firebase");
                    

Unregister a Device


await client.removeDevice(
    '2ffca4ad6599adc9b5202d15a5286d33c19547d472cd09de44219cda5ac30207', 
    '42'
)
                    

client.delete_device(
    '2ffca4ad6599adc9b5202d15a5286d33c19547d472cd09de44219cda5ac30207', 
    '42'
)
                    

client.delete_device(
    '2ffca4ad6599adc9b5202d15a5286d33c19547d472cd09de44219cda5ac30207', 
    '42'
)
                    

client.removeDevice(deviceToken, new CompletableCallback() { ... });
                    

Client.shared.removeDevice(deviceId: device.id).subscribe().disposed(by: disposeBag)
                    

stream chat:push:device:delete \
    --device_id '2ffca4ad6599adc9b5202d15a5286d33c19547d472cd09de44219cda5ac30207'
    --user_id '42'
                    

$delete = $client->deleteDevice(
    '2ffca4ad6599adc9b5202d15a5286d33c19547d472cd09de44219cda5ac30207', 
    'elon'
);
                    

await client.removeDevice("device-token");