ctx := context.Background()
resp, err := client.CreateDevice(ctx, &getstream.CreateDeviceRequest{
Id: "<push token>",
UserId: "<user id>",
})
if err != nil {
// handle error
}
Push Notifications
We suggest setting up push notifications using one of Stream’s client-side SDKs. However, if your use-case doesn’t allow for this, you can call Stream’s device management endpoints from your server-side integration as well. Stream API supports the following push providers: Firebase Cloud Messaging, Apple Push Notification (APN), Huawei Push and Xiaomi Push.
Configuring push providers
More information on how to configure push providers is coming soon.
Device management
Device management lets you register your push tokens to the Stream API, which is used to deliver push notifications.
Creating a device
Listing devices
If you want to list the devices that are registered to the current user, you should use the ListDevices
method:
ctx := context.Background()
resp, err := client.ListDevices(ctx, &getstream.ListDevicesRequest{
UserId: "<user id>",
})
if err != nil {
// handle error
}
// Access the devices
devices := resp.Data.Devices
The device contains the following properties:
type Device struct {
CreatedAt time.Time `json:"created_at"`
Id string `json:"id"`
PushProvider string `json:"push_provider"`
UserId string `json:"user_id"`
Disabled *bool `json:"disabled,omitempty"`
DisabledReason *string `json:"disabled_reason,omitempty"`
PushProviderName *string `json:"push_provider_name,omitempty"`
Voip *bool `json:"voip,omitempty"`
}
Removing devices
ctx := context.Background()
resp, err := client.DeleteDevice(ctx, &getstream.DeleteDeviceRequest{
Id: "<device id>",
UserId: "<user id>",
})
if err != nil {
// handle error
}
- I'm working with the Stream Feeds Go SDK and would like to ask questions about this documentation page: https://getstream.io/activity-feeds/docs/go-golang/push-notifications.md
- View as markdown
- Open in ChatGPT
- Open in Claude