Activity Feeds V3 is in closed alpha — do not use it in production (just yet).

Push Notifications

Push notifications are sent for different types of events, such as adding a comment or reaction.

Registering a device for push notifications

To receive push notifications, you need to register the device with Stream. This is done by using the createDevice function, passing the device token you receive from your push notification provider (Firebase Cloud Messaging, Huawei Push Kit, Xiaomi Mi Push).

You should have these providers configured on your dashboard. If you don’t have them, an error will be thrown when trying to add a device.

For example, if you were using Firebase Cloud Messaging, you would do:

val token = firebaseMessaging.token.await()

client.createDevice(
    id = token,
    pushProvider = PushNotificationsProvider.FIREBASE,
    pushProviderName = "firebase-push-provider",
)

You will then start receiving push notifications in your FirebaseMessagingService implementation.

class FeedsFirebaseMessagingService : FirebaseMessagingService() {

    override fun onMessageReceived(message: RemoteMessage) {
        super.onMessageReceived(message)
        // Extract the relevant information from the remote message
        val title = message.data["title"]
        val body = message.data["body"]

        // Show the notification
    }

    // Your service implementation
}

Removing devices

To stop receiving notifications, you can delete the device by passing the token you used to create it:

feedsClient.deleteDevice(deviceId = pushToken)

Listing devices

If you want to list the devices that are registered to the current user, you can use the queryDevices function:

val devices: Result<ListDevicesResponse> = client.queryDevices()

This function’s return contains a list of DeviceResponse, which contains information about the device:

public val createdAt: Date
public val disabled: Bool?
public val disabledReason: String?
public val id: String
public val pushProvider: String
public val pushProviderName: String?
public val userId: String
© Getstream.io, Inc. All Rights Reserved.