@azure/notification-hubs 1.0.0-beta.5 → 1.0.0-beta.6
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 +28 -44
- package/dist/index.cjs +390 -310
- package/dist/index.cjs.map +1 -1
- package/dist-esm/src/client/beginSubmitNotificationHubJob.js +131 -0
- package/dist-esm/src/client/beginSubmitNotificationHubJob.js.map +1 -0
- package/dist-esm/src/client/cancelScheduledNotification.js +1 -1
- package/dist-esm/src/client/cancelScheduledNotification.js.map +1 -1
- package/dist-esm/src/client/createOrUpdateInstallation.js +1 -1
- package/dist-esm/src/client/createOrUpdateInstallation.js.map +1 -1
- package/dist-esm/src/client/createOrUpdateRegistration.js +1 -1
- package/dist-esm/src/client/createOrUpdateRegistration.js.map +1 -1
- package/dist-esm/src/client/createRegistration.js +1 -1
- package/dist-esm/src/client/createRegistration.js.map +1 -1
- package/dist-esm/src/client/createRegistrationId.js +1 -1
- package/dist-esm/src/client/createRegistrationId.js.map +1 -1
- package/dist-esm/src/client/deleteInstallation.js +1 -1
- package/dist-esm/src/client/deleteInstallation.js.map +1 -1
- package/dist-esm/src/client/deleteRegistration.js +1 -1
- package/dist-esm/src/client/deleteRegistration.js.map +1 -1
- package/dist-esm/src/client/getFeedbackContainerUrl.js +1 -1
- package/dist-esm/src/client/getFeedbackContainerUrl.js.map +1 -1
- package/dist-esm/src/client/getInstallation.js +1 -1
- package/dist-esm/src/client/getInstallation.js.map +1 -1
- package/dist-esm/src/client/getNotificationHubJob.js +1 -1
- package/dist-esm/src/client/getNotificationHubJob.js.map +1 -1
- package/dist-esm/src/client/getNotificationOutcomeDetails.js +1 -1
- package/dist-esm/src/client/getNotificationOutcomeDetails.js.map +1 -1
- package/dist-esm/src/client/getRegistration.js +1 -1
- package/dist-esm/src/client/getRegistration.js.map +1 -1
- package/dist-esm/src/client/index.js +2 -2
- package/dist-esm/src/client/index.js.map +1 -1
- package/dist-esm/src/client/listNotificationHubJobs.js +1 -1
- package/dist-esm/src/client/listNotificationHubJobs.js.map +1 -1
- package/dist-esm/src/client/listRegistrations.js +1 -1
- package/dist-esm/src/client/listRegistrations.js.map +1 -1
- package/dist-esm/src/client/listRegistrationsByTag.js +1 -1
- package/dist-esm/src/client/listRegistrationsByTag.js.map +1 -1
- package/dist-esm/src/client/scheduleNotification.js +20 -6
- package/dist-esm/src/client/scheduleNotification.js.map +1 -1
- package/dist-esm/src/client/sendNotification.js +53 -6
- package/dist-esm/src/client/sendNotification.js.map +1 -1
- package/dist-esm/src/client/submitNotificationHubJob.js +1 -1
- package/dist-esm/src/client/submitNotificationHubJob.js.map +1 -1
- package/dist-esm/src/client/updateInstallation.js +1 -1
- package/dist-esm/src/client/updateInstallation.js.map +1 -1
- package/dist-esm/src/client/updateRegistration.js +1 -1
- package/dist-esm/src/client/updateRegistration.js.map +1 -1
- package/dist-esm/src/models/notificationHubJob.js.map +1 -1
- package/dist-esm/src/models/options.js.map +1 -1
- package/dist-esm/src/notificationHubsClient.js +16 -45
- package/dist-esm/src/notificationHubsClient.js.map +1 -1
- package/dist-esm/src/serializers/notificationDetailsSerializer.js +2 -1
- package/dist-esm/src/serializers/notificationDetailsSerializer.js.map +1 -1
- package/dist-esm/src/serializers/notificationHubJobSerializer.js +3 -1
- package/dist-esm/src/serializers/notificationHubJobSerializer.js.map +1 -1
- package/dist-esm/src/utils/constants.js +1 -1
- package/dist-esm/src/utils/constants.js.map +1 -1
- package/dist-esm/src/utils/notificationUtils.js +25 -0
- package/dist-esm/src/utils/notificationUtils.js.map +1 -0
- package/dist-esm/src/utils/optionUtils.js +20 -0
- package/dist-esm/src/utils/optionUtils.js.map +1 -0
- package/package.json +6 -5
- package/types/3.1/notification-hubs.d.ts +52 -36
- package/types/latest/notification-hubs.d.ts +56 -36
- package/types/latest/tsdoc-metadata.json +1 -1
- package/types/src/client/beginSubmitNotificationHubJob.d.ts +12 -0
- package/types/src/client/beginSubmitNotificationHubJob.d.ts.map +1 -0
- package/types/src/client/index.d.ts +1 -1
- package/types/src/client/index.d.ts.map +1 -1
- package/types/src/client/scheduleNotification.d.ts +3 -5
- package/types/src/client/scheduleNotification.d.ts.map +1 -1
- package/types/src/client/sendNotification.d.ts +3 -5
- package/types/src/client/sendNotification.d.ts.map +1 -1
- package/types/src/models/notificationHubJob.d.ts +5 -0
- package/types/src/models/notificationHubJob.d.ts.map +1 -1
- package/types/src/models/options.d.ts +36 -2
- package/types/src/models/options.d.ts.map +1 -1
- package/types/src/notificationHubsClient.d.ts +14 -37
- package/types/src/notificationHubsClient.d.ts.map +1 -1
- package/types/src/utils/notificationUtils.d.ts +10 -0
- package/types/src/utils/notificationUtils.d.ts.map +1 -0
- package/types/src/utils/optionUtils.d.ts +14 -0
- package/types/src/utils/optionUtils.d.ts.map +1 -0
- package/dist-esm/src/client/internal/_scheduleNotificationPayload.js +0 -38
- package/dist-esm/src/client/internal/_scheduleNotificationPayload.js.map +0 -1
- package/dist-esm/src/client/internal/_sendNotificationPayload.js +0 -51
- package/dist-esm/src/client/internal/_sendNotificationPayload.js.map +0 -1
- package/dist-esm/src/client/scheduleBroadcastNotification.js +0 -17
- package/dist-esm/src/client/scheduleBroadcastNotification.js.map +0 -1
- package/dist-esm/src/client/sendBroadcastNotification.js +0 -15
- package/dist-esm/src/client/sendBroadcastNotification.js.map +0 -1
- package/dist-esm/src/client/sendDirectNotification.js +0 -15
- package/dist-esm/src/client/sendDirectNotification.js.map +0 -1
- package/types/src/client/internal/_scheduleNotificationPayload.d.ts +0 -9
- package/types/src/client/internal/_scheduleNotificationPayload.d.ts.map +0 -1
- package/types/src/client/internal/_sendNotificationPayload.d.ts +0 -10
- package/types/src/client/internal/_sendNotificationPayload.d.ts.map +0 -1
- package/types/src/client/scheduleBroadcastNotification.d.ts +0 -16
- package/types/src/client/scheduleBroadcastNotification.d.ts.map +0 -1
- package/types/src/client/sendBroadcastNotification.d.ts +0 -14
- package/types/src/client/sendBroadcastNotification.d.ts.map +0 -1
- package/types/src/client/sendDirectNotification.d.ts +0 -15
- package/types/src/client/sendDirectNotification.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ Key links:
|
|
|
20
20
|
|
|
21
21
|
### Currently supported environments
|
|
22
22
|
|
|
23
|
-
- [LTS versions of Node.js](https://
|
|
23
|
+
- [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule)
|
|
24
24
|
- Latest versions of Safari, Chrome, Edge, and Firefox.
|
|
25
25
|
|
|
26
26
|
See our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md) for more details.
|
|
@@ -359,7 +359,7 @@ for await (const pages of registrations.byPage()) {
|
|
|
359
359
|
|
|
360
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.
|
|
361
361
|
|
|
362
|
-
For debugging purposes, the `enableTestSend` options can be set to `true` which gets immediate feedback from the PNS on the `sendNotification`
|
|
362
|
+
For debugging purposes, the `enableTestSend` options can be set to `true` which gets immediate feedback from the PNS on the `sendNotification` method, however, is not supported in production scenarios. This is not supported on the scheduled send methods.
|
|
363
363
|
|
|
364
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.
|
|
365
365
|
|
|
@@ -370,7 +370,6 @@ import { buildAppleNativeMessage } from "@azure/notification-hubs";
|
|
|
370
370
|
// Using the modular approach
|
|
371
371
|
import { buildAppleNativeMessage } from "@azure/notification-hubs/models/notificationBuilder";
|
|
372
372
|
|
|
373
|
-
|
|
374
373
|
const apnsMessage = buildAppleNativeMessage({
|
|
375
374
|
alert: {
|
|
376
375
|
title: "Notification Title",
|
|
@@ -383,17 +382,16 @@ const apnsMessage = buildAppleNativeMessage({
|
|
|
383
382
|
|
|
384
383
|
// Send the message using the modular approach
|
|
385
384
|
|
|
386
|
-
const result = await
|
|
385
|
+
const result = await sendNotification(context, apnsMessage);
|
|
387
386
|
```
|
|
388
387
|
|
|
389
388
|
#### Broadcast Send
|
|
390
389
|
|
|
391
|
-
Notification Hubs can be used to send notifications to all registered devices per platform using broadcast send through the `
|
|
390
|
+
Notification Hubs can be used to send notifications to all registered devices per platform using broadcast send through the `sendNotification` method.
|
|
392
391
|
|
|
393
392
|
```typescript
|
|
394
393
|
import {
|
|
395
394
|
NotificationHubServiceClient,
|
|
396
|
-
SendOperationOptions,
|
|
397
395
|
createAppleNotification,
|
|
398
396
|
} from "@azure/notification-hubs/client";
|
|
399
397
|
|
|
@@ -409,9 +407,7 @@ const message = createAppleNotification({
|
|
|
409
407
|
},
|
|
410
408
|
});
|
|
411
409
|
|
|
412
|
-
|
|
413
|
-
const sendOptions: SendOperationOptions = { enableTestSend: false };
|
|
414
|
-
const result = await client.sendBroadcastNotification(message, sendOptions);
|
|
410
|
+
const result = await client.sendNotification(message);
|
|
415
411
|
|
|
416
412
|
console.log(`Tracking ID: ${result.trackingId}`);
|
|
417
413
|
console.log(`Correlation ID: ${result.correlationId}`);
|
|
@@ -425,10 +421,9 @@ if (result.notificationId) {
|
|
|
425
421
|
Using the modular approach, the code would be as follows:
|
|
426
422
|
|
|
427
423
|
```typescript
|
|
428
|
-
import { SendOperationOptions } from "@azure/notification-hubs/models/options";
|
|
429
424
|
import { createClientContext } from "@azure/notification-hubs/client";
|
|
430
425
|
import { createAppleNotification } from "@azure/notification-hubs/models/notification";
|
|
431
|
-
import {
|
|
426
|
+
import { sendNotification } from "@azure/notification-hubs/client/sendNotification";
|
|
432
427
|
|
|
433
428
|
const context = createClientContext(connectionString, hubName);
|
|
434
429
|
|
|
@@ -442,9 +437,7 @@ const message = createAppleNotification({
|
|
|
442
437
|
},
|
|
443
438
|
});
|
|
444
439
|
|
|
445
|
-
|
|
446
|
-
const sendOptions: SendOperationOptions = { enableTestSend: false };
|
|
447
|
-
const result = await sendBroadcastNotification(context, message, sendOptions);
|
|
440
|
+
const result = await sendNotification(context, message);
|
|
448
441
|
|
|
449
442
|
console.log(`Tracking ID: ${result.trackingId}`);
|
|
450
443
|
console.log(`Correlation ID: ${result.correlationId}`);
|
|
@@ -457,18 +450,17 @@ if (result.notificationId) {
|
|
|
457
450
|
|
|
458
451
|
#### Direct Send
|
|
459
452
|
|
|
460
|
-
To send directly a device, the user can send using the platform provided unique identifier such as APNs device token by calling the `
|
|
453
|
+
To send directly a device, the user can send using the platform provided unique identifier such as APNs device token by calling the `sendNotification` method with a `deviceHandle` parameter.
|
|
461
454
|
|
|
462
455
|
```typescript
|
|
463
456
|
import {
|
|
464
457
|
NotificationHubServiceClient,
|
|
465
|
-
SendOperationOptions,
|
|
466
458
|
createAppleNotification,
|
|
467
459
|
} from "@azure/notification-hubs";
|
|
468
460
|
|
|
469
461
|
const client = new NotificationHubServiceClient(connectionString, hubName);
|
|
470
462
|
|
|
471
|
-
const
|
|
463
|
+
const deviceHandle = "00fc13adff785122b4ad28809a3420982341241421348097878e577c991de8f0";
|
|
472
464
|
const messageBody = `{ "aps" : { "alert" : "Hello" } }`;
|
|
473
465
|
|
|
474
466
|
const message = createAppleNotification({
|
|
@@ -479,7 +471,7 @@ const message = createAppleNotification({
|
|
|
479
471
|
},
|
|
480
472
|
});
|
|
481
473
|
|
|
482
|
-
const result = await client.
|
|
474
|
+
const result = await client.sendNotification(message, { deviceHandle });
|
|
483
475
|
|
|
484
476
|
console.log(`Tracking ID: ${result.trackingId}`);
|
|
485
477
|
console.log(`Correlation ID: ${result.correlationId}`);
|
|
@@ -493,14 +485,13 @@ if (result.notificationId) {
|
|
|
493
485
|
Using the modular approach, the code would be as follows:
|
|
494
486
|
|
|
495
487
|
```typescript
|
|
496
|
-
import { SendOperationOptions } from "@azure/notification-hubs/models/options";
|
|
497
488
|
import { createClientContext } from "@azure/notification-hubs/client";
|
|
498
489
|
import { createAppleNotification } from "@azure/notification-hubs/models/notification";
|
|
499
|
-
import {
|
|
490
|
+
import { sendNotification } from "@azure/notification-hubs/client/sendDirectNotification";
|
|
500
491
|
|
|
501
492
|
const context = createClientContext(connectionString, hubName);
|
|
502
493
|
|
|
503
|
-
const
|
|
494
|
+
const deviceHandle = "00fc13adff785122b4ad28809a3420982341241421348097878e577c991de8f0";
|
|
504
495
|
const messageBody = `{ "aps" : { "alert" : "Hello" } }`;
|
|
505
496
|
|
|
506
497
|
const message = createAppleNotification({
|
|
@@ -511,7 +502,7 @@ const message = createAppleNotification({
|
|
|
511
502
|
},
|
|
512
503
|
});
|
|
513
504
|
|
|
514
|
-
const result = await
|
|
505
|
+
const result = await sendNotification(context, message, { deviceHandle });
|
|
515
506
|
|
|
516
507
|
console.log(`Tracking ID: ${result.trackingId}`);
|
|
517
508
|
console.log(`Correlation ID: ${result.correlationId}`);
|
|
@@ -529,8 +520,7 @@ In addition to targeting a single device, a user can target multiple devices usi
|
|
|
529
520
|
```typescript
|
|
530
521
|
import {
|
|
531
522
|
NotificationHubServiceClient,
|
|
532
|
-
|
|
533
|
-
createAppleMessage,
|
|
523
|
+
createAppleNotification,
|
|
534
524
|
} from "@azure/notification-hubs";
|
|
535
525
|
|
|
536
526
|
const client = new NotificationHubServiceClient("<connection string>", "<hub name>");
|
|
@@ -538,7 +528,7 @@ const client = new NotificationHubServiceClient("<connection string>", "<hub nam
|
|
|
538
528
|
const tagExpression = "likes_hockey && likes_football";
|
|
539
529
|
const messageBody = `{ "aps" : { "alert" : "Hello" } }`;
|
|
540
530
|
|
|
541
|
-
const
|
|
531
|
+
const notification = createAppleNotification({
|
|
542
532
|
body: messageBody,
|
|
543
533
|
headers: {
|
|
544
534
|
"apns-priority": "10",
|
|
@@ -546,10 +536,7 @@ const message = createAppleMessage({
|
|
|
546
536
|
},
|
|
547
537
|
});
|
|
548
538
|
|
|
549
|
-
|
|
550
|
-
// Not required but can set test send to true for debugging purposes.
|
|
551
|
-
const sendOptions: SendOperationOptions = { enableTestSend: false };
|
|
552
|
-
const result = await client.sendNotification(tagExpression, message, sendOptions);
|
|
539
|
+
const result = await client.sendNotification(notification, { tags: tagExpression });
|
|
553
540
|
|
|
554
541
|
console.log(`Tracking ID: ${result.trackingId}`);
|
|
555
542
|
console.log(`Correlation ID: ${result.correlationId}`);
|
|
@@ -563,7 +550,6 @@ if (result.notificationId) {
|
|
|
563
550
|
Using the modular approach, the code would be as follows:
|
|
564
551
|
|
|
565
552
|
```typescript
|
|
566
|
-
import { SendOperationOptions } from "@azure/notification-hubs/models/options";
|
|
567
553
|
import { createClientContext } from "@azure/notification-hubs/client";
|
|
568
554
|
import { createAppleNotification } from "@azure/notification-hubs/models/notification";
|
|
569
555
|
import { sendNotification } from "@azure/notification-hubs/client/sendNotification";
|
|
@@ -573,7 +559,7 @@ const context = createClientContext("<connection string>", "<hub name>");
|
|
|
573
559
|
const tagExpression = "likes_hockey && likes_football";
|
|
574
560
|
const messageBody = `{ "aps" : { "alert" : "Hello" } }`;
|
|
575
561
|
|
|
576
|
-
const
|
|
562
|
+
const notification = createAppleNotification({
|
|
577
563
|
body: messageBody,
|
|
578
564
|
headers: {
|
|
579
565
|
"apns-priority": "10",
|
|
@@ -581,10 +567,7 @@ const message = createAppleMessage({
|
|
|
581
567
|
},
|
|
582
568
|
});
|
|
583
569
|
|
|
584
|
-
|
|
585
|
-
// Not required but can set test send to true for debugging purposes.
|
|
586
|
-
const sendOptions: SendOperationOptions = { enableTestSend: false };
|
|
587
|
-
const result = await sendNotification(context, tagExpression, message, sendOptions);
|
|
570
|
+
const result = await sendNotification(context, notification, { tags: tagExpression });
|
|
588
571
|
|
|
589
572
|
console.log(`Tracking ID: ${result.trackingId}`);
|
|
590
573
|
console.log(`Correlation ID: ${result.correlationId}`);
|
|
@@ -597,12 +580,11 @@ if (result.notificationId) {
|
|
|
597
580
|
|
|
598
581
|
#### Scheduled Send
|
|
599
582
|
|
|
600
|
-
Push notifications can be scheduled up to seven days in advance with Standard SKU namespaces and above using the `scheduleBroadcastNotification` method to send to devices with tags or a general broadcast
|
|
583
|
+
Push notifications can be scheduled up to seven days in advance with Standard SKU namespaces and above using the `scheduleBroadcastNotification` method to send to devices with tags or a general broadcast. This returns a notification ID which can be then used to cancel if necessary via the `cancelScheduledNotification` method.
|
|
601
584
|
|
|
602
585
|
```typescript
|
|
603
586
|
import {
|
|
604
587
|
NotificationHubServiceClient,
|
|
605
|
-
SendOperationOptions,
|
|
606
588
|
createAppleNotification,
|
|
607
589
|
} from "@azure/notification-hubs";
|
|
608
590
|
|
|
@@ -611,7 +593,7 @@ const client = new NotificationHubServiceClient("<connection string>", "<hub nam
|
|
|
611
593
|
const tagExpression = "likes_hockey && likes_football";
|
|
612
594
|
const messageBody = `{ "aps" : { "alert" : "Hello" } }`;
|
|
613
595
|
|
|
614
|
-
// Schedule 8 hours from
|
|
596
|
+
// Schedule 8 hours from now
|
|
615
597
|
const scheduledTime = new Date(Date.now() + (8 * 60 * 60 * 1000));
|
|
616
598
|
|
|
617
599
|
const message = createAppleNotification({
|
|
@@ -622,7 +604,7 @@ const message = createAppleNotification({
|
|
|
622
604
|
},
|
|
623
605
|
});
|
|
624
606
|
|
|
625
|
-
const result = await client.scheduleNotification(scheduledTime,
|
|
607
|
+
const result = await client.scheduleNotification(scheduledTime, message, { tags: tagExpression });
|
|
626
608
|
|
|
627
609
|
console.log(`Tracking ID: ${result.trackingId}`);
|
|
628
610
|
console.log(`Correlation ID: ${result.correlationId}`);
|
|
@@ -634,7 +616,6 @@ console.log(`Notification ID: ${result.notificationId}`);
|
|
|
634
616
|
Using the modular approach, the code would be as follows:
|
|
635
617
|
|
|
636
618
|
```typescript
|
|
637
|
-
import { SendOperationOptions } from "@azure/notification-hubs/models/options";
|
|
638
619
|
import { createClientContext } from "@azure/notification-hubs/client";
|
|
639
620
|
import { createAppleNotification } from "@azure/notification-hubs/models/notification";
|
|
640
621
|
import { scheduleNotification } from "@azure/notification-hubs/client/scheduleNotification";
|
|
@@ -644,7 +625,7 @@ const context = createClientContext("<connection string>", "<hub name>");
|
|
|
644
625
|
const tagExpression = "likes_hockey && likes_football";
|
|
645
626
|
const messageBody = `{ "aps" : { "alert" : "Hello" } }`;
|
|
646
627
|
|
|
647
|
-
// Schedule 8 hours from
|
|
628
|
+
// Schedule 8 hours from now
|
|
648
629
|
const scheduledTime = new Date(Date.now() + (8 * 60 * 60 * 1000));
|
|
649
630
|
|
|
650
631
|
const message = createAppleNotification({
|
|
@@ -655,7 +636,7 @@ const message = createAppleNotification({
|
|
|
655
636
|
},
|
|
656
637
|
});
|
|
657
638
|
|
|
658
|
-
const result = await scheduleNotification(context, scheduledTime,
|
|
639
|
+
const result = await scheduleNotification(context, scheduledTime, message, { tags: tagExpression });
|
|
659
640
|
|
|
660
641
|
console.log(`Tracking ID: ${result.trackingId}`);
|
|
661
642
|
console.log(`Correlation ID: ${result.correlationId}`);
|
|
@@ -673,8 +654,11 @@ Azure Notification Hubs has a complete guide to troubleshooting problems with dr
|
|
|
673
654
|
[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:
|
|
674
655
|
|
|
675
656
|
```typescript
|
|
676
|
-
|
|
677
|
-
const result = await client.sendNotification(
|
|
657
|
+
// Using the client
|
|
658
|
+
const result = await client.sendNotification(message, { tags, enableTestSend: true });
|
|
659
|
+
|
|
660
|
+
// Using the modular approach
|
|
661
|
+
const result = await sendNotification(context, notification, { tags, enableTestSend: true });
|
|
678
662
|
```
|
|
679
663
|
|
|
680
664
|
### Logging
|