Push notification device metadata
How to use channel data to store device-level metadata for push notifications.
When setting channel data for push channels, Knock provides the option to set additional metadata alongside a device token. When set, a device-level locale will be used when translating message content for the device, and the timezone will be used to evalute send windows.
This feature is available for all push providers except OneSignal.
Availability
#How it works
#When setting a recipient's channel data for a supported push channel, you can pass a list of devices objects (containing token, locale, and timezone) rather than a list of tokens strings.
When a workflow includes a push channel step and the recipient channel data includes device metadata, any device-level values will take precedence over the recipient-level locale and timezone properties. This means:
- The translation language used to render message content for the device will be according to the device-level
localeproperty. - The timezone used to evaluate the send window for the device will be according to the device-level
timezoneproperty.
All other features of push channels (including token deregistration) will function the same way, regardless of whether device metadata is set.
Setting device metadata
#In the example below, we're setting a user's device token by passing devices rather than tokens.
If you do not require device-level locale or timezone properties, you can simply set channel data by passing a list of tokens strings.
Getting push channel data
#Regardless of whether you set tokens or devices, you'll see them returned in both formats when retrieving channel data. Devices will include null values for the locale and timezone properties if they were not provided when channel data was set.