From 43824b4be324dec798dc0613646738598f0bebf2 Mon Sep 17 00:00:00 2001 From: A-KGeorge Date: Thu, 17 Oct 2024 14:03:00 -0230 Subject: [PATCH 1/2] added identify section --- docs/reference/js-core.md | 93 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) diff --git a/docs/reference/js-core.md b/docs/reference/js-core.md index 7cc3f50..efa5a4b 100644 --- a/docs/reference/js-core.md +++ b/docs/reference/js-core.md @@ -109,3 +109,96 @@ await client.updateDeliveryOption({ delivery: 'off', }); ``` + +## identify + +Stores the end-user information for a given user. + +By using this function, you can omit the contact information when using send(). NotificationAPI will automatically lookup the user's stored email or phone number and use it for sending the notification. + +```javascript +const res = await client.identify({ + id: 'spongebob.squarepants', + email: 'spongebob@squarepants.com', + number: '+15005550006', + pushTokens: [ + { + type: PushProviders.FCM, + token: 'samplePushToken', + device: { + app_id: 'com.example.app', + ad_id: '1234567890', + device_id: '1234567890', + platform: 'android', + manufacturer: 'Samsung', + model: 'SM-G930F' + } + } + ], + webPushTokens: [ + { + sub: { + endpoint: + 'https://fcm.googleapis.com/fcm/send/fCs_4iba0Ao:APA91bGFdaU7I3****JMH_KeZwk1Xi', + keys: { + p256dh: + 'zP2xFu3hMc2vNH5E2nuKkyjpZydvCk9llRUY2kP4****9aSlKcoadSV2UbvMRQ', + auth: 'CXEFun************tYe8g' + } + } + } + ] +}); + +console.log(res); +``` + +### Parameters + +| Name | Type | Description | +| --------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `id`\* | string | The ID of the user in your system. Required. | +| `email` | string | Required for sending email notifications, otherwise optional. | +| `number` | string | Required for SMS/CALL notifications, otherwise optional. Valid format: +15005550006. Unformatted US/Canada numbers are also accepted, e.g., (415) 555-1212, 415-555-1212, or 4155551212. | +| `timezone` | string | The user's timezone. Timezone names correspond to the Zone and Link names of the IANA Time Zone Database, such as 'America/New_York', 'America/Denver', 'EST', and 'UTC'. | +| `pushTokens` | object[] | Tokens which are required to send mobile push notifications, a user can have multiple devices and a push token is required for each device. | +| `webPushTokens` | object[] | Tokens which are required to send web push notification, a user can have multiple devices and a web push token is required for each device. | + +#### pushTokens object + +| Name | Type | Description | +| ---------- | ------ | -------------------------------------------------------------------- | +| `type`\* | string | [apn,fcm] The provider token is to be associated with. Required. | +| `token`\* | string | The full token string. Required. | +| `device`\* | object | Information about the device the token is associated with. Required. | + +##### device object + +| Name | Type | Description | +| -------------- | ------ | -------------------------------------------------------- | +| `app_id` | string | Id of the application the token is used for. | +| `ad_id` | string | Id of the advertising identifier. | +| `device`\* | string | Id of the device the token is associated with. Required. | +| `platform` | string | The device platform i.e. android, ios. | +| `manufacturer` | string | The device manufacturer. | +| `model` | string | The device model . | + +#### webPushTokens object + +| Name | Type | Description | +| ------- | ------ | -------------------------------- | +| `sub`\* | object | Web push subscription. Required. | + +##### Web push subscription (sub) object + +| Name | Type | Description | +| ------------ | ------ | ----------------------------------------------------------------------------------------- | +| `endpoint`\* | string | The string value containing the endpoint associated with the push subscription. Required. | +| `keys`\* | object | The keys associated with the push subscription. Required. | + +##### Web push subscription keys object + +| Name | Type | Description | +| ---------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `p256dh`\* | string | An Elliptic curve Diffie–Hellman public key on the P-256 curve (that is, the NIST secp256r1 elliptic curve). The resulting key is an uncompressed point in ANSI X9.62 format. Required. | +| `auth`\* | string | An authentication secret, as described in Message Encryption for Web Push. Required. | From ae6f75284f7b012ad0f78a9156a245410112bfa1 Mon Sep 17 00:00:00 2001 From: A-KGeorge Date: Thu, 17 Oct 2024 15:11:55 -0230 Subject: [PATCH 2/2] changed sub headings --- docs/reference/js-core.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/reference/js-core.md b/docs/reference/js-core.md index efa5a4b..04b182d 100644 --- a/docs/reference/js-core.md +++ b/docs/reference/js-core.md @@ -172,7 +172,7 @@ console.log(res); | `token`\* | string | The full token string. Required. | | `device`\* | object | Information about the device the token is associated with. Required. | -##### device object +#### device object | Name | Type | Description | | -------------- | ------ | -------------------------------------------------------- | @@ -189,14 +189,14 @@ console.log(res); | ------- | ------ | -------------------------------- | | `sub`\* | object | Web push subscription. Required. | -##### Web push subscription (sub) object +#### Web push subscription (sub) object | Name | Type | Description | | ------------ | ------ | ----------------------------------------------------------------------------------------- | | `endpoint`\* | string | The string value containing the endpoint associated with the push subscription. Required. | | `keys`\* | object | The keys associated with the push subscription. Required. | -##### Web push subscription keys object +#### Web push subscription keys object | Name | Type | Description | | ---------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |