@azure/notification-hubs 1.0.0-beta.1 → 1.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -20
- package/dist/{index.js → index.cjs} +245 -146
- package/dist/index.cjs.map +1 -0
- package/dist-esm/src/{utils → auth}/connectionStringUtils.js +37 -1
- package/dist-esm/src/auth/connectionStringUtils.js.map +1 -0
- package/dist-esm/src/auth/hmacSha256.browser.js +12 -0
- package/dist-esm/src/auth/hmacSha256.browser.js.map +1 -0
- package/dist-esm/src/auth/hmacSha256.js +8 -0
- package/dist-esm/src/auth/hmacSha256.js.map +1 -0
- package/dist-esm/src/auth/sasTokenProvider.js +58 -0
- package/dist-esm/src/auth/sasTokenProvider.js.map +1 -0
- package/dist-esm/src/client/cancelScheduledNotification.js +3 -2
- package/dist-esm/src/client/cancelScheduledNotification.js.map +1 -1
- package/dist-esm/src/client/createOrUpdateInstallation.js +3 -2
- package/dist-esm/src/client/createOrUpdateInstallation.js.map +1 -1
- package/dist-esm/src/client/createOrUpdateRegistration.js +2 -1
- package/dist-esm/src/client/createOrUpdateRegistration.js.map +1 -1
- package/dist-esm/src/client/createRegistration.js +2 -1
- package/dist-esm/src/client/createRegistration.js.map +1 -1
- package/dist-esm/src/client/createRegistrationId.js +3 -2
- package/dist-esm/src/client/createRegistrationId.js.map +1 -1
- package/dist-esm/src/client/deleteInstallation.js +3 -2
- package/dist-esm/src/client/deleteInstallation.js.map +1 -1
- package/dist-esm/src/client/deleteRegistration.js +3 -2
- package/dist-esm/src/client/deleteRegistration.js.map +1 -1
- package/dist-esm/src/client/getFeedbackContainerUrl.js +3 -2
- package/dist-esm/src/client/getFeedbackContainerUrl.js.map +1 -1
- package/dist-esm/src/client/getInstallation.js +3 -2
- package/dist-esm/src/client/getInstallation.js.map +1 -1
- package/dist-esm/src/client/getNotificationHubJob.js +3 -2
- package/dist-esm/src/client/getNotificationHubJob.js.map +1 -1
- package/dist-esm/src/client/getNotificationOutcomeDetails.js +3 -2
- package/dist-esm/src/client/getNotificationOutcomeDetails.js.map +1 -1
- package/dist-esm/src/client/getRegistration.js +3 -2
- package/dist-esm/src/client/getRegistration.js.map +1 -1
- package/dist-esm/src/client/index.js +7 -3
- package/dist-esm/src/client/index.js.map +1 -1
- package/dist-esm/src/client/internal/_client.js +23 -7
- package/dist-esm/src/client/internal/_client.js.map +1 -1
- package/dist-esm/src/client/internal/_createOrUpdateRegistrationDescription.js +1 -1
- package/dist-esm/src/client/internal/_createOrUpdateRegistrationDescription.js.map +1 -1
- package/dist-esm/src/client/internal/_scheduleNotificationPayload.js +3 -2
- package/dist-esm/src/client/internal/_scheduleNotificationPayload.js.map +1 -1
- package/dist-esm/src/client/internal/_sendNotificationPayload.js +2 -2
- package/dist-esm/src/client/internal/_sendNotificationPayload.js.map +1 -1
- package/dist-esm/src/client/listNotificationHubJobs.js +3 -2
- package/dist-esm/src/client/listNotificationHubJobs.js.map +1 -1
- package/dist-esm/src/client/listRegistrations.js +3 -2
- package/dist-esm/src/client/listRegistrations.js.map +1 -1
- package/dist-esm/src/client/listRegistrationsByTag.js +3 -2
- package/dist-esm/src/client/listRegistrationsByTag.js.map +1 -1
- package/dist-esm/src/client/scheduleBroadcastNotification.js.map +1 -1
- package/dist-esm/src/client/scheduleNotification.js.map +1 -1
- package/dist-esm/src/client/sendBroadcastNotification.js.map +1 -1
- package/dist-esm/src/client/sendDirectNotification.js +1 -2
- package/dist-esm/src/client/sendDirectNotification.js.map +1 -1
- package/dist-esm/src/client/sendNotification.js.map +1 -1
- package/dist-esm/src/client/submitNotificationHubJob.js +3 -2
- package/dist-esm/src/client/submitNotificationHubJob.js.map +1 -1
- package/dist-esm/src/client/updateInstallation.js +3 -2
- package/dist-esm/src/client/updateInstallation.js.map +1 -1
- package/dist-esm/src/client/updateRegistration.js +2 -1
- package/dist-esm/src/client/updateRegistration.js.map +1 -1
- package/dist-esm/src/models/installation.js +1 -1
- package/dist-esm/src/models/installation.js.map +1 -1
- package/dist-esm/src/models/notification.js +1 -1
- package/dist-esm/src/models/notification.js.map +1 -1
- package/dist-esm/src/models/notificationBuilder.js +6 -6
- package/dist-esm/src/models/notificationBuilder.js.map +1 -1
- package/dist-esm/src/models/notificationDetails.js.map +1 -1
- package/dist-esm/src/models/registration.js +3 -39
- package/dist-esm/src/models/registration.js.map +1 -1
- package/dist-esm/src/models/response.js.map +1 -1
- package/dist-esm/src/notificationHubsClient.js +1 -2
- package/dist-esm/src/notificationHubsClient.js.map +1 -1
- package/dist-esm/src/serializers/notificationHubJobSerializer.js +3 -0
- package/dist-esm/src/serializers/notificationHubJobSerializer.js.map +1 -1
- package/dist-esm/src/serializers/notificationOutcomeSerializer.js +31 -0
- package/dist-esm/src/serializers/notificationOutcomeSerializer.js.map +1 -0
- package/dist-esm/src/serializers/registrationSerializer.js +3 -28
- package/dist-esm/src/serializers/registrationSerializer.js.map +1 -1
- package/dist-esm/src/utils/constants.js +1 -0
- package/dist-esm/src/utils/constants.js.map +1 -1
- package/dist-esm/src/utils/retryPolicy.js +2 -2
- package/dist-esm/src/utils/retryPolicy.js.map +1 -1
- package/dist-esm/src/utils/tracing.js +2 -1
- package/dist-esm/src/utils/tracing.js.map +1 -1
- package/package.json +18 -13
- package/types/3.1/notification-hubs.d.ts +60 -77
- package/types/latest/notification-hubs.d.ts +61 -83
- package/types/latest/tsdoc-metadata.json +1 -1
- package/types/src/{utils → auth}/connectionStringUtils.d.ts +7 -1
- package/types/src/auth/connectionStringUtils.d.ts.map +1 -0
- package/types/src/auth/hmacSha256.browser.d.ts +3 -0
- package/types/src/auth/hmacSha256.browser.d.ts.map +1 -0
- package/types/src/auth/hmacSha256.d.ts +2 -0
- package/types/src/auth/hmacSha256.d.ts.map +1 -0
- package/types/src/auth/sasTokenProvider.d.ts +77 -0
- package/types/src/auth/sasTokenProvider.d.ts.map +1 -0
- package/types/src/client/cancelScheduledNotification.d.ts +1 -1
- package/types/src/client/cancelScheduledNotification.d.ts.map +1 -1
- package/types/src/client/createOrUpdateInstallation.d.ts +1 -1
- package/types/src/client/createOrUpdateInstallation.d.ts.map +1 -1
- package/types/src/client/createOrUpdateRegistration.d.ts.map +1 -1
- package/types/src/client/createRegistration.d.ts.map +1 -1
- package/types/src/client/createRegistrationId.d.ts.map +1 -1
- package/types/src/client/deleteInstallation.d.ts +1 -1
- package/types/src/client/deleteInstallation.d.ts.map +1 -1
- package/types/src/client/deleteRegistration.d.ts +1 -1
- package/types/src/client/deleteRegistration.d.ts.map +1 -1
- package/types/src/client/getFeedbackContainerUrl.d.ts.map +1 -1
- package/types/src/client/getInstallation.d.ts.map +1 -1
- package/types/src/client/getNotificationHubJob.d.ts.map +1 -1
- package/types/src/client/getNotificationOutcomeDetails.d.ts.map +1 -1
- package/types/src/client/getRegistration.d.ts.map +1 -1
- package/types/src/client/index.d.ts +2 -3
- package/types/src/client/index.d.ts.map +1 -1
- package/types/src/client/internal/_client.d.ts +8 -8
- package/types/src/client/internal/_client.d.ts.map +1 -1
- package/types/src/client/internal/_scheduleNotificationPayload.d.ts +1 -1
- package/types/src/client/internal/_scheduleNotificationPayload.d.ts.map +1 -1
- package/types/src/client/internal/_sendNotificationPayload.d.ts +1 -1
- package/types/src/client/internal/_sendNotificationPayload.d.ts.map +1 -1
- package/types/src/client/listNotificationHubJobs.d.ts.map +1 -1
- package/types/src/client/listRegistrations.d.ts.map +1 -1
- package/types/src/client/listRegistrationsByTag.d.ts.map +1 -1
- package/types/src/client/scheduleBroadcastNotification.d.ts +1 -1
- package/types/src/client/scheduleBroadcastNotification.d.ts.map +1 -1
- package/types/src/client/scheduleNotification.d.ts +1 -1
- package/types/src/client/scheduleNotification.d.ts.map +1 -1
- package/types/src/client/sendBroadcastNotification.d.ts +1 -1
- package/types/src/client/sendBroadcastNotification.d.ts.map +1 -1
- package/types/src/client/sendDirectNotification.d.ts +4 -5
- package/types/src/client/sendDirectNotification.d.ts.map +1 -1
- package/types/src/client/sendNotification.d.ts +1 -1
- package/types/src/client/sendNotification.d.ts.map +1 -1
- package/types/src/client/submitNotificationHubJob.d.ts.map +1 -1
- package/types/src/client/updateInstallation.d.ts +1 -1
- package/types/src/client/updateInstallation.d.ts.map +1 -1
- package/types/src/client/updateRegistration.d.ts.map +1 -1
- package/types/src/models/installation.d.ts +3 -3
- package/types/src/models/installation.d.ts.map +1 -1
- package/types/src/models/notification.d.ts +3 -3
- package/types/src/models/notification.d.ts.map +1 -1
- package/types/src/models/notificationBuilder.d.ts +4 -4
- package/types/src/models/notificationBuilder.d.ts.map +1 -1
- package/types/src/models/notificationDetails.d.ts +63 -0
- package/types/src/models/notificationDetails.d.ts.map +1 -1
- package/types/src/models/registration.d.ts +6 -59
- package/types/src/models/registration.d.ts.map +1 -1
- package/types/src/models/response.d.ts +0 -26
- package/types/src/models/response.d.ts.map +1 -1
- package/types/src/notificationHubsClient.d.ts +3 -5
- package/types/src/notificationHubsClient.d.ts.map +1 -1
- package/types/src/serializers/notificationHubJobSerializer.d.ts.map +1 -1
- package/types/src/serializers/notificationOutcomeSerializer.d.ts +3 -0
- package/types/src/serializers/notificationOutcomeSerializer.d.ts.map +1 -0
- package/types/src/serializers/registrationSerializer.d.ts +1 -21
- package/types/src/serializers/registrationSerializer.d.ts.map +1 -1
- package/types/src/utils/constants.d.ts +1 -0
- package/types/src/utils/constants.d.ts.map +1 -1
- package/types/src/utils/tracing.d.ts.map +1 -1
- package/dist/index.js.map +0 -1
- package/dist-esm/src/utils/connectionStringUtils.js.map +0 -1
- package/types/src/utils/connectionStringUtils.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -9,8 +9,12 @@ Azure Notification Hubs provide a scaled-out push engine that enables you to sen
|
|
|
9
9
|
- Notify users of enterprise events such as new messages and work items.
|
|
10
10
|
- Send codes for multi-factor authentication.
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
Key links:
|
|
13
|
+
|
|
14
|
+
- [Source code](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/notificationhubs/notification-hubs/)
|
|
15
|
+
- [Package (npm)](https://www.npmjs.com/package/@azure/notification-hubs)
|
|
16
|
+
- [Product documentation](https://docs.microsoft.com/azure/notification-hubs/)
|
|
17
|
+
- [Samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/notificationhubs/notification-hubs/samples-dev)
|
|
14
18
|
|
|
15
19
|
## Getting started
|
|
16
20
|
|
|
@@ -134,7 +138,7 @@ Device management is a core concept to Notification Hubs to be able to store the
|
|
|
134
138
|
Installations are a newer and native JSON approach to device management that contains additional properties such as an installation ID and user ID which can be used for sending to audiences. The installations API has a few advantages over the existing Registration APIs in the following ways:
|
|
135
139
|
|
|
136
140
|
- Fully idempotent API so calling create on the installation, so an operation can be retried without worries about duplications.
|
|
137
|
-
- Support for `userId` and `installationId` properties which can be then used in tag expressions such as `$InstallationId:myInstallId` and `$UserId:bob@contoso.com`.
|
|
141
|
+
- Support for `userId` and `installationId` properties which can be then used in tag expressions such as `$InstallationId:{myInstallId}` and `$UserId:{bob@contoso.com}`.
|
|
138
142
|
- Templates are now part of the installation instead of a separate registration and can be reference by name as a tag for sending.
|
|
139
143
|
- Partial updates are supported through the [JSON Patch Standard](https://tools.ietf.org/html/rfc6902), which allows to add tags and change other data without having to first query the installation.
|
|
140
144
|
|
|
@@ -355,7 +359,7 @@ for await (const pages of registrations.byPage()) {
|
|
|
355
359
|
|
|
356
360
|
Notification Hubs supports sending notifications to devices either directly using the unique PNS provided identifier, using tags for audience send, or a general broadcast to all devices. Using the Standard SKU and above, [scheduled send](https://docs.microsoft.com/azure/notification-hubs/notification-hubs-send-push-notifications-scheduled) allows the user to schedule notifications up to seven days in advance. All send operations return a Tracking ID and Correlation ID which can be used for Notification Hubs support cases. With the Standard SKU and above, a Notification ID is also returned which can be used to get notification telemetry via the `getNotificationOutcomeDetails` method.
|
|
357
361
|
|
|
358
|
-
For debugging purposes, the `enableTestSend` options can be set to `true` which gets immediate feedback from the PNS on the `
|
|
362
|
+
For debugging purposes, the `enableTestSend` options can be set to `true` which gets immediate feedback from the PNS on the `sendNotification` or `sendBroadcastNotification` methods, however, is not supported in production scenarios. This is not supported on the scheduled send methods.
|
|
359
363
|
|
|
360
364
|
Raw JSON or XML strings can be sent to the send or scheduled send methods, or the notification builders can be used which helps construct messages per PNS such as APNs, Firebase, Baidu, ADM and WNS. These builders will build the native message format and fill in associated HTTP headers so there is no guessing about which fields are available for each PNS.
|
|
361
365
|
|
|
@@ -366,6 +370,7 @@ import { buildAppleNativeMessage } from "@azure/notification-hubs";
|
|
|
366
370
|
// Using the modular approach
|
|
367
371
|
import { buildAppleNativeMessage } from "@azure/notification-hubs/models/notificationBuilder";
|
|
368
372
|
|
|
373
|
+
|
|
369
374
|
const apnsMessage = buildAppleNativeMessage({
|
|
370
375
|
alert: {
|
|
371
376
|
title: "Notification Title",
|
|
@@ -377,6 +382,7 @@ const apnsMessage = buildAppleNativeMessage({
|
|
|
377
382
|
});
|
|
378
383
|
|
|
379
384
|
// Send the message using the modular approach
|
|
385
|
+
|
|
380
386
|
const result = await sendBroadcastNotification(context, apnsMessage);
|
|
381
387
|
```
|
|
382
388
|
|
|
@@ -473,9 +479,7 @@ const message = createAppleNotification({
|
|
|
473
479
|
},
|
|
474
480
|
});
|
|
475
481
|
|
|
476
|
-
|
|
477
|
-
const sendOptions: SendOperationOptions = { enableTestSend: false };
|
|
478
|
-
const result = await client.sendDirectNotification(devicetoken, message, sendOptions);
|
|
482
|
+
const result = await client.sendDirectNotification(devicetoken, message);
|
|
479
483
|
|
|
480
484
|
console.log(`Tracking ID: ${result.trackingId}`);
|
|
481
485
|
console.log(`Correlation ID: ${result.correlationId}`);
|
|
@@ -507,8 +511,6 @@ const message = createAppleNotification({
|
|
|
507
511
|
},
|
|
508
512
|
});
|
|
509
513
|
|
|
510
|
-
// Not required but can set test send to true for debugging purposes.
|
|
511
|
-
const sendOptions: SendOperationOptions = { enableTestSend: false };
|
|
512
514
|
const result = await sendDirectNotification(context, devicetoken, message, sendOptions);
|
|
513
515
|
|
|
514
516
|
console.log(`Tracking ID: ${result.trackingId}`);
|
|
@@ -620,9 +622,7 @@ const message = createAppleNotification({
|
|
|
620
622
|
},
|
|
621
623
|
});
|
|
622
624
|
|
|
623
|
-
|
|
624
|
-
const sendOptions: SendOperationOptions = { enableTestSend: false };
|
|
625
|
-
const result = await client.scheduleNotification(scheduledTime, tagExpression, message, sendOptions);
|
|
625
|
+
const result = await client.scheduleNotification(scheduledTime, tagExpression, message);
|
|
626
626
|
|
|
627
627
|
console.log(`Tracking ID: ${result.trackingId}`);
|
|
628
628
|
console.log(`Correlation ID: ${result.correlationId}`);
|
|
@@ -655,9 +655,7 @@ const message = createAppleNotification({
|
|
|
655
655
|
},
|
|
656
656
|
});
|
|
657
657
|
|
|
658
|
-
|
|
659
|
-
const sendOptions: SendOperationOptions = { enableTestSend: false };
|
|
660
|
-
const result = await scheduleNotification(context, scheduledTime, tagExpression, message, sendOptions);
|
|
658
|
+
const result = await scheduleNotification(context, scheduledTime, tagExpression, message);
|
|
661
659
|
|
|
662
660
|
console.log(`Tracking ID: ${result.trackingId}`);
|
|
663
661
|
console.log(`Correlation ID: ${result.correlationId}`);
|
|
@@ -672,11 +670,11 @@ console.log(`Notification ID: ${result.notificationId}`);
|
|
|
672
670
|
|
|
673
671
|
Azure Notification Hubs has a complete guide to troubleshooting problems with dropped notifications in the [Diagnose dropped notifications in Azure Notification Hubs Guide](https://docs.microsoft.com/azure/notification-hubs/notification-hubs-push-notification-fixer).
|
|
674
672
|
|
|
675
|
-
[Test send](https://docs.microsoft.com/azure/notification-hubs/notification-hubs-push-notification-fixer#enabletestsend-property) is supported supported in the
|
|
673
|
+
[Test send](https://docs.microsoft.com/azure/notification-hubs/notification-hubs-push-notification-fixer#enabletestsend-property) is supported supported in the `sendNotification` method with the `enableTestSend` option:
|
|
676
674
|
|
|
677
675
|
```typescript
|
|
678
676
|
const sendOptions: SendOperationOptions = { enableTestSend: true };
|
|
679
|
-
const result = await client.
|
|
677
|
+
const result = await client.sendNotification(tags, message, sendOptions);
|
|
680
678
|
```
|
|
681
679
|
|
|
682
680
|
### Logging
|
|
@@ -744,6 +742,3 @@ folder for more details.
|
|
|
744
742
|
- [Azure Notification Hubs](https://docs.microsoft.com/azure/notification-hubs/notification-hubs-push-notification-overview)
|
|
745
743
|
|
|
746
744
|

|
|
747
|
-
|
|
748
|
-
[azure_cli]: https://docs.microsoft.com/cli/azure
|
|
749
|
-
[azure_sub]: https://azure.microsoft.com/free/
|