You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(KNO-10408): Update docs around Channel Data Tokens + Devices (#1202)
* a
* a
* a
* a
* a
* chore: update device metadata docs
* chore: additional updates and formatting
* format
* chore: update example response to match code example
* address feedback
* small edit for clarity
---------
Co-authored-by: Matt Kufchak <matt@knock.app>
Copy file name to clipboardExpand all lines: content/integrations/push/apns.mdx
+6-3Lines changed: 6 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -81,6 +81,9 @@ Overrides are merged into the notification payload sent to APNs. See the <a href
81
81
82
82
In order to use a configured APNs channel you must store a list of one or more device tokens for the user or the object that you wish to deliver a notification to. You can retrieve a device token by following the tutorial in the <ahref="https://developer.apple.com/documentation/usernotifications/registering_your_app_with_apns"target="_blank">Apple developer documentation</a>.
| tokens\*|`string[]`| One or more device tokens. Required when not using `devices`. |
89
+
| devices\*|[`PushDevice[]`](/managing-recipients/setting-channel-data#the-pushdevice-object)| One or more device objects. Required when not using `tokens`. |
Copy file name to clipboardExpand all lines: content/integrations/push/aws-sns.mdx
+6-3Lines changed: 6 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -305,6 +305,9 @@ See <a href="https://docs.aws.amazon.com/sns/latest/dg/sns-message-attributes.ht
305
305
306
306
In order to use a configured Amazon SNS channel, you must store a list of one or more platform endpoint ARNs for the user or the object that you wish to deliver a notification to. See <ahref="https://docs.aws.amazon.com/sns/latest/dg/mobile-platform-endpoint.html"target="_blank">Setting up an Amazon SNS platform endpoint for mobile notifications</a> for more details on creating platform endpoints.
| target_arns\*|`string[]`| One or more platform endpoint ARNs associated with a platform application and a device token. Required when not using `devices`. |
313
+
| devices\*|[`PushDevice[]`](/managing-recipients/setting-channel-data#the-pushdevice-object)| One or more device objects. Required when not using `target_arns`. |
description: How to use channel data to store device-level metadata for push notifications.
4
+
tags:
5
+
[
6
+
"push token",
7
+
"channel data",
8
+
"device token",
9
+
"device metadata",
10
+
"locale",
11
+
"timezone",
12
+
]
13
+
section: Integrations > Push
14
+
layout: integrations
15
+
---
16
+
17
+
When [setting channel data for push channels](/managing-recipients/setting-channel-data#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](/concepts/translations) message content for the device, and the `timezone` will be used to evalute [send windows](/designing-workflows/send-windows).
18
+
19
+
This feature is available for all push providers except OneSignal.
20
+
21
+
## Availability
22
+
23
+
| Provider | Device metadata supported? |
24
+
| ---------- | -------------------------- |
25
+
| APNs | ✅ |
26
+
| FCM | ✅ |
27
+
| Expo | ✅ |
28
+
| Amazon SNS | ✅ |
29
+
| OneSignal | ❌ |
30
+
31
+
## How it works
32
+
33
+
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.
34
+
35
+
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](/managing-recipients/identifying-recipients#reserved-properties). This means:
36
+
37
+
- The translation language used to render message content for the device will be according to the device-level `locale` property.
38
+
- The timezone used to evaluate the send window for the device will be according to the device-level `timezone` property.
39
+
40
+
All other features of push channels (including [token deregistration](/integrations/push/token-deregistration)) will function the same way, regardless of whether device metadata is set.
41
+
42
+
<Callout
43
+
type="warning"
44
+
title="Note:"
45
+
text={
46
+
<>
47
+
If you're using Knock's Amazon SNS push notification integration, a{""}
48
+
<code>target_arn</code> or <code>target_arns</code> will take the place of{""}
49
+
<code>token</code> or <code>tokens</code> when setting channel data. Their
50
+
functionality is interchangeable. Reference the{""}
In the example below, we're setting a user's device token by passing `devices` rather than `tokens`.
60
+
61
+
<MultiLangCodeBlock
62
+
snippet="users.setChannelDataDevices"
63
+
title="Set push channel data for a user via devices"
64
+
/>
65
+
66
+
If you do not require device-level locale or timezone properties, you can simply set channel data by passing a list of `tokens` strings.
67
+
68
+
<MultiLangCodeBlock
69
+
snippet="users.setChannelData"
70
+
title="Set push channel data for a user via tokens"
71
+
/>
72
+
73
+
### Getting push channel data
74
+
75
+
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.
76
+
77
+
```json title="Example push channel data response"
Copy file name to clipboardExpand all lines: content/integrations/push/expo.mdx
+6-3Lines changed: 6 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -60,6 +60,9 @@ Overrides are merged into the notification payload sent to Expo. See the <a href
60
60
61
61
In order to use a configured Expo channel you must store a list of one or more device tokens for the user or the object that you wish to deliver a notification to. You can retrieve a device token by following the tutorial in the <ahref="https://docs.expo.dev/push-notifications/push-notifications-setup/"target="_blank">Expo developer documentation</a>.
| tokens\*|`string[]`| One or more device tokens. Required when not using `devices`. |
68
+
| devices\*|[`PushDevice[]`](/managing-recipients/setting-channel-data#the-pushdevice-object)| One or more device objects. Required when not using `tokens`. |
Copy file name to clipboardExpand all lines: content/integrations/push/firebase.mdx
+7-4Lines changed: 7 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -142,8 +142,11 @@ The following are common FCM errors you may see in your message delivery logs:
142
142
143
143
## Channel data requirements
144
144
145
-
In order to use a configured FCM channel you must store a list of one or more device tokens for the user or the object that you wish to deliver a notification to. If you use multiple device tokens for a single user or object, Knock will generate and try and deliver a notification for each unique token.
145
+
In order to use a configured FCM channel you must store a list of one or more device tokens for the user or the object that you wish to deliver a notification to. If you use multiple device tokens for a single user or object, Knock will generate and try to deliver a notification for each unique token.
| tokens\*|`string[]`| One or more device tokens. Required when not using `devices`. |
152
+
| devices\*|[`PushDevice[]`](/managing-recipients/setting-channel-data#the-pushdevice-object)| One or more device objects. Required when not using `tokens`. |
Copy file name to clipboardExpand all lines: content/integrations/push/overview.mdx
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,8 @@ Knock supports sending push notifications directly to native services such as Ap
12
12
13
13
-**No stateful connections to manage**: we take care of all of the complexity of managing and maintaining stateful connections to your push providers, just simply send us notifications and we'll get them delivered!
14
14
-**Cross-provider, single template**: you can send the same templated message across multiple providers to reduce the amount of templates to maintain.
15
-
-**Token deregistration**: if a recipient's token(s) is invalid resulting in a `bounced` message when attempting to send, remove the token.
15
+
-[**Token deregistration**](/integrations/push/token-deregistration): if a recipient's invalid device token results in a `bounced` message when attempting to send, Knock can optionally remove the token.
16
+
-[**Device metadata**](/integrations/push/device-metadata): set device-level `locale` and `timezone` properties for translations and send window evaluation with supported providers.
Copy file name to clipboardExpand all lines: content/integrations/push/token-deregistration.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ section: Integrations > Push
6
6
layout: integrations
7
7
---
8
8
9
-
For push providers only, Knock provides an opt-in, provider-agnostic token management capability known as token deregistration. Knock removes invalid tokens from a recipient's corresponding channel data if that token results in a `bounced` message on send.
9
+
For push providers only, Knock provides an opt-in, provider-agnostic token management capability known as token deregistration. Knock removes invalid tokens (and devices, when using [device metadata](/integrations/push/device-metadata)) from a recipient's corresponding channel data if that token results in a `bounced` message on send.
10
10
11
11
This feature is available for all push providers, except OneSignal when the recipient mode is set to `external_id`. In this case, Knock only has access to the user's ID and therefore cannot deregister the associated external token.
Copy file name to clipboardExpand all lines: content/managing-recipients/setting-channel-data.mdx
+49-13Lines changed: 49 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ At Knock we call this concept <a href="/api-reference/recipients/channel_data">`
13
13
14
14
- For channel types that require channel data (such as [push](/integrations/push/overview) channels and [chat](/integrations/chat/overview) channels like Slack), the channel step will be skipped during a workflow run if the required `channel_data` is not stored on the recipient.
15
15
- Knock stores channel data for you but makes no assumptions about whether the stored channel data is valid. That means that if a push token expires, it's your responsibility to omit/update that token for future notifications.
16
-
- For push providers, Knock offers an opt-in [token deregistration](/integrations/push/token-deregistration) feature that automatically removes invalid tokens from a recipient's channel data when messages bounce.
16
+
- For push providers, Knock offers an opt-in [token deregistration](/integrations/push/token-deregistration) feature that automatically removes invalid tokens from a recipient's channel data when messages bounce.
17
17
- Setting channel data always requires a `channel_id`, which can be obtained in the Dashboard under the **Channels and sources** page in your account settings. A channel ID is always a UUID v4.
18
18
19
19
## Setting channel data
@@ -134,27 +134,63 @@ Any previously set channel data can be cleared by issuing an `unsetChannelData`
134
134
135
135
## Provider data requirements
136
136
137
-
Channel data requirements for each provider are listed below. Typically `channel_data` comprises a `token` or other value that is used to uniquely identify a user's device.
137
+
Channel data requirements for each channel type and provider are listed below. Typically `channel_data` comprises a `token` or other value that is used to uniquely identify a user's device.
| tokens\*|`string[]`| One or more device tokens |
141
+
You can set push channel data by passing either:
142
+
143
+
- A list of `tokens` (or `target_arns` for [Amazon SNS](/integrations/push/aws-sns)) strings
144
+
- A list of `devices` objects for supported push providers. If set, this [device-level metadata](/integrations/push/device-metadata) will be used when evaluating [translations](/concepts/translations) and [send windows](/designing-workflows/send-windows).
145
+
146
+
#### The `PushDevice` object
147
+
148
+
The `PushDevice` object is used to optionally set device-level metadata for a push channel. It contains the following properties:
| token\*|`string`| The device token to send the push notification to. Required for providers other than Amazon SNS. |
153
+
| target_arn\*|`string`| The ARN of a platform endpoint associated with a platform application and a device token. Required for Amazon SNS. |
154
+
| locale |`string`| The [locale](/concepts/translations#supported-locales) of the device. |
155
+
| timezone |`string`| The timezone of the device. Must be a valid [tz database time zone string](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). |
0 commit comments