Skip to content

Commit 0a35f46

Browse files
mogitaclaude
andcommitted
feat: add migration guide for devices (CHA-2592)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d7eb23a commit 0a35f46

1 file changed

Lines changed: 140 additions & 0 deletions

File tree

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
# Devices
2+
3+
This guide covers migrating device management operations (push notification setup) from `stream-chat-php` to `getstream-php`.
4+
5+
## Adding a Device
6+
7+
### APN (Apple Push Notifications)
8+
9+
**Before (stream-chat-php):**
10+
11+
```php
12+
use GetStream\StreamChat\Client;
13+
14+
$client = new Client("<api-key>", "<api-secret>");
15+
16+
$client->addDevice("device-token-abc", "apn", "user-123");
17+
18+
// With a named push provider configuration
19+
$client->addDevice("device-token-abc", "apn", "user-123", "my-apn-provider");
20+
```
21+
22+
**After (getstream-php):**
23+
24+
```php
25+
use GetStream\ChatClient;
26+
use GetStream\GeneratedModels\CreateDeviceRequest;
27+
28+
$client = new ChatClient("<api-key>", "<api-secret>");
29+
30+
$client->createDevice(new CreateDeviceRequest(
31+
id: 'device-token-abc',
32+
pushProvider: 'apn',
33+
userID: 'user-123',
34+
));
35+
36+
// With a named push provider configuration
37+
$client->createDevice(new CreateDeviceRequest(
38+
id: 'device-token-abc',
39+
pushProvider: 'apn',
40+
userID: 'user-123',
41+
pushProviderName: 'my-apn-provider',
42+
));
43+
```
44+
45+
> **Key differences:**
46+
> - Method renamed from `addDevice()` to `createDevice()`
47+
> - Uses a `CreateDeviceRequest` object with named arguments instead of positional string parameters
48+
> - Push provider and user ID are properties on the request object
49+
50+
### Firebase (Android Push Notifications)
51+
52+
**Before (stream-chat-php):**
53+
54+
```php
55+
$client->addDevice("fcm-token-xyz", "firebase", "user-123");
56+
57+
// With a named push provider configuration
58+
$client->addDevice("fcm-token-xyz", "firebase", "user-123", "my-firebase-provider");
59+
```
60+
61+
**After (getstream-php):**
62+
63+
```php
64+
use GetStream\GeneratedModels\CreateDeviceRequest;
65+
66+
$client->createDevice(new CreateDeviceRequest(
67+
id: 'fcm-token-xyz',
68+
pushProvider: 'firebase',
69+
userID: 'user-123',
70+
));
71+
72+
// With a named push provider configuration
73+
$client->createDevice(new CreateDeviceRequest(
74+
id: 'fcm-token-xyz',
75+
pushProvider: 'firebase',
76+
userID: 'user-123',
77+
pushProviderName: 'my-firebase-provider',
78+
));
79+
```
80+
81+
### VoIP Token (Apple)
82+
83+
The new SDK adds support for registering Apple VoIP push tokens, which was not available as a dedicated option in the old SDK.
84+
85+
**After (getstream-php):**
86+
87+
```php
88+
use GetStream\GeneratedModels\CreateDeviceRequest;
89+
90+
$client->createDevice(new CreateDeviceRequest(
91+
id: 'voip-token-abc',
92+
pushProvider: 'apn',
93+
userID: 'user-123',
94+
voipToken: true,
95+
));
96+
```
97+
98+
## Listing Devices for a User
99+
100+
**Before (stream-chat-php):**
101+
102+
```php
103+
$response = $client->getDevices("user-123");
104+
```
105+
106+
**After (getstream-php):**
107+
108+
```php
109+
$response = $client->listDevices('user-123');
110+
```
111+
112+
> **Key differences:**
113+
> - Method renamed from `getDevices()` to `listDevices()`
114+
> - Response is typed as `ListDevicesResponse` instead of a generic `StreamResponse`
115+
116+
## Deleting a Device
117+
118+
**Before (stream-chat-php):**
119+
120+
```php
121+
$client->deleteDevice("device-token-abc", "user-123");
122+
```
123+
124+
**After (getstream-php):**
125+
126+
```php
127+
$client->deleteDevice('device-token-abc', 'user-123');
128+
```
129+
130+
> **Key differences:**
131+
> - The method signature is the same: `deleteDevice(string $id, string $userID)`
132+
> - Parameter names changed from `$deviceId` to `$id` and `$userId` to `$userID`, but since both are positional strings this has no practical impact
133+
134+
## Method Mapping Summary
135+
136+
| Operation | stream-chat-php | getstream-php |
137+
|-----------|----------------|---------------|
138+
| Add device | `$client->addDevice($deviceId, $provider, $userId, $providerName)` | `$client->createDevice(new CreateDeviceRequest(...))` |
139+
| List devices | `$client->getDevices($userId)` | `$client->listDevices($userID)` |
140+
| Delete device | `$client->deleteDevice($deviceId, $userId)` | `$client->deleteDevice($id, $userID)` |

0 commit comments

Comments
 (0)