Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added identify section #121

Merged
merged 2 commits into from
Oct 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions docs/reference/js-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: '[email protected]',
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. |