@azure/notification-hubs 1.0.0-alpha.20220906.2 → 1.0.0-alpha.20220909.5

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.
Files changed (98) hide show
  1. package/README.md +15 -20
  2. package/dist/index.cjs +73 -118
  3. package/dist/index.cjs.map +1 -1
  4. package/dist-esm/src/auth/hmacSha256.browser.js +1 -0
  5. package/dist-esm/src/auth/hmacSha256.browser.js.map +1 -1
  6. package/dist-esm/src/auth/sasTokenProvider.js +2 -23
  7. package/dist-esm/src/auth/sasTokenProvider.js.map +1 -1
  8. package/dist-esm/src/client/cancelScheduledNotification.js.map +1 -1
  9. package/dist-esm/src/client/createOrUpdateInstallation.js.map +1 -1
  10. package/dist-esm/src/client/deleteInstallation.js.map +1 -1
  11. package/dist-esm/src/client/deleteRegistration.js.map +1 -1
  12. package/dist-esm/src/client/internal/_client.js +23 -7
  13. package/dist-esm/src/client/internal/_client.js.map +1 -1
  14. package/dist-esm/src/client/internal/_scheduleNotificationPayload.js.map +1 -1
  15. package/dist-esm/src/client/internal/_sendNotificationPayload.js +1 -1
  16. package/dist-esm/src/client/internal/_sendNotificationPayload.js.map +1 -1
  17. package/dist-esm/src/client/scheduleBroadcastNotification.js.map +1 -1
  18. package/dist-esm/src/client/scheduleNotification.js.map +1 -1
  19. package/dist-esm/src/client/sendBroadcastNotification.js.map +1 -1
  20. package/dist-esm/src/client/sendDirectNotification.js +1 -2
  21. package/dist-esm/src/client/sendDirectNotification.js.map +1 -1
  22. package/dist-esm/src/client/sendNotification.js.map +1 -1
  23. package/dist-esm/src/client/updateInstallation.js.map +1 -1
  24. package/dist-esm/src/models/installation.js +1 -1
  25. package/dist-esm/src/models/installation.js.map +1 -1
  26. package/dist-esm/src/models/notification.js +1 -1
  27. package/dist-esm/src/models/notification.js.map +1 -1
  28. package/dist-esm/src/models/notificationBuilder.js +6 -6
  29. package/dist-esm/src/models/notificationBuilder.js.map +1 -1
  30. package/dist-esm/src/models/notificationDetails.js.map +1 -1
  31. package/dist-esm/src/models/registration.js +3 -39
  32. package/dist-esm/src/models/registration.js.map +1 -1
  33. package/dist-esm/src/models/response.js.map +1 -1
  34. package/dist-esm/src/notificationHubsClient.js +1 -2
  35. package/dist-esm/src/notificationHubsClient.js.map +1 -1
  36. package/dist-esm/src/serializers/notificationHubJobSerializer.js +3 -0
  37. package/dist-esm/src/serializers/notificationHubJobSerializer.js.map +1 -1
  38. package/dist-esm/src/serializers/notificationOutcomeSerializer.js +31 -0
  39. package/dist-esm/src/serializers/notificationOutcomeSerializer.js.map +1 -0
  40. package/dist-esm/src/serializers/registrationSerializer.js +0 -28
  41. package/dist-esm/src/serializers/registrationSerializer.js.map +1 -1
  42. package/dist-esm/src/utils/constants.js +1 -1
  43. package/dist-esm/src/utils/constants.js.map +1 -1
  44. package/package.json +3 -3
  45. package/types/3.1/notification-hubs.d.ts +60 -77
  46. package/types/latest/notification-hubs.d.ts +61 -83
  47. package/types/latest/tsdoc-metadata.json +1 -1
  48. package/types/src/auth/hmacSha256.browser.d.ts +1 -0
  49. package/types/src/auth/hmacSha256.browser.d.ts.map +1 -1
  50. package/types/src/auth/sasTokenProvider.d.ts +28 -8
  51. package/types/src/auth/sasTokenProvider.d.ts.map +1 -1
  52. package/types/src/client/cancelScheduledNotification.d.ts +1 -1
  53. package/types/src/client/cancelScheduledNotification.d.ts.map +1 -1
  54. package/types/src/client/createOrUpdateInstallation.d.ts +1 -1
  55. package/types/src/client/createOrUpdateInstallation.d.ts.map +1 -1
  56. package/types/src/client/deleteInstallation.d.ts +1 -1
  57. package/types/src/client/deleteInstallation.d.ts.map +1 -1
  58. package/types/src/client/deleteRegistration.d.ts +1 -1
  59. package/types/src/client/deleteRegistration.d.ts.map +1 -1
  60. package/types/src/client/index.d.ts +0 -1
  61. package/types/src/client/index.d.ts.map +1 -1
  62. package/types/src/client/internal/_client.d.ts +8 -8
  63. package/types/src/client/internal/_client.d.ts.map +1 -1
  64. package/types/src/client/internal/_scheduleNotificationPayload.d.ts +1 -1
  65. package/types/src/client/internal/_scheduleNotificationPayload.d.ts.map +1 -1
  66. package/types/src/client/internal/_sendNotificationPayload.d.ts +1 -1
  67. package/types/src/client/internal/_sendNotificationPayload.d.ts.map +1 -1
  68. package/types/src/client/scheduleBroadcastNotification.d.ts +1 -1
  69. package/types/src/client/scheduleBroadcastNotification.d.ts.map +1 -1
  70. package/types/src/client/scheduleNotification.d.ts +1 -1
  71. package/types/src/client/scheduleNotification.d.ts.map +1 -1
  72. package/types/src/client/sendBroadcastNotification.d.ts +1 -1
  73. package/types/src/client/sendBroadcastNotification.d.ts.map +1 -1
  74. package/types/src/client/sendDirectNotification.d.ts +4 -5
  75. package/types/src/client/sendDirectNotification.d.ts.map +1 -1
  76. package/types/src/client/sendNotification.d.ts +1 -1
  77. package/types/src/client/sendNotification.d.ts.map +1 -1
  78. package/types/src/client/updateInstallation.d.ts +1 -1
  79. package/types/src/client/updateInstallation.d.ts.map +1 -1
  80. package/types/src/models/installation.d.ts +3 -3
  81. package/types/src/models/installation.d.ts.map +1 -1
  82. package/types/src/models/notification.d.ts +3 -3
  83. package/types/src/models/notification.d.ts.map +1 -1
  84. package/types/src/models/notificationBuilder.d.ts +4 -4
  85. package/types/src/models/notificationBuilder.d.ts.map +1 -1
  86. package/types/src/models/notificationDetails.d.ts +63 -0
  87. package/types/src/models/notificationDetails.d.ts.map +1 -1
  88. package/types/src/models/registration.d.ts +6 -59
  89. package/types/src/models/registration.d.ts.map +1 -1
  90. package/types/src/models/response.d.ts +0 -26
  91. package/types/src/models/response.d.ts.map +1 -1
  92. package/types/src/notificationHubsClient.d.ts +3 -5
  93. package/types/src/notificationHubsClient.d.ts.map +1 -1
  94. package/types/src/serializers/notificationHubJobSerializer.d.ts.map +1 -1
  95. package/types/src/serializers/notificationOutcomeSerializer.d.ts +3 -0
  96. package/types/src/serializers/notificationOutcomeSerializer.d.ts.map +1 -0
  97. package/types/src/serializers/registrationSerializer.d.ts +1 -21
  98. package/types/src/serializers/registrationSerializer.d.ts.map +1 -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
- [Source code](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/notificationhubs/notification-hubs/) |
13
- [Product documentation](https://docs.microsoft.com/azure/notification-hubs/)
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 `send*` methods, however, is not supported in production scenarios. This is not supported on the scheduled send methods.
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
- // Not required but can set test send to true for debugging purposes.
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
- // Not required but can set test send to true for debugging purposes.
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
- // Not required but can set test send to true for debugging purposes.
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 send methods with the `enableTestSend` option:
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.sendDirectNotification(devicetoken, message, sendOptions);
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
  ![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%notificationhubs%2Fnotification-hubs%2FREADME.png)
747
-
748
- [azure_cli]: https://docs.microsoft.com/cli/azure
749
- [azure_sub]: https://azure.microsoft.com/free/
package/dist/index.cjs CHANGED
@@ -3,8 +3,6 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var coreRestPipeline = require('@azure/core-rest-pipeline');
6
- var coreAuth = require('@azure/core-auth');
7
- var coreUtil = require('@azure/core-util');
8
6
  var crypto = require('crypto');
9
7
  var coreXml = require('@azure/core-xml');
10
8
  var coreClient = require('@azure/core-client');
@@ -13,7 +11,7 @@ var tslib = require('tslib');
13
11
 
14
12
  // Copyright (c) Microsoft Corporation.
15
13
  // Licensed under the MIT license.
16
- const SDK_VERSION = "1.0.0-beta.4";
14
+ const SDK_VERSION = "1.0.0-beta.5";
17
15
  const JSON_CONTENT_TYPE = "application/json;charset=utf-8";
18
16
  const XML_CONTENT_TYPE = "application/xml";
19
17
  const STREAM_CONTENT_TYPE = "application/octet-stream";
@@ -36,18 +34,7 @@ async function signString(key, toSign) {
36
34
  * @hidden
37
35
  */
38
36
  function createSasTokenProvider(data) {
39
- if (coreAuth.isNamedKeyCredential(data) || coreAuth.isSASCredential(data)) {
40
- return new SasTokenProviderImpl(data);
41
- }
42
- else if (coreUtil.isObjectWithProperties(data, ["sharedAccessKeyName", "sharedAccessKey"])) {
43
- return new SasTokenProviderImpl({
44
- name: data.sharedAccessKeyName,
45
- key: data.sharedAccessKey,
46
- });
47
- }
48
- else {
49
- return new SasTokenProviderImpl({ signature: data.sharedAccessSignature });
50
- }
37
+ return new SasTokenProviderImpl(data);
51
38
  }
52
39
  /**
53
40
  * A TokenProvider that generates a Sas token:
@@ -74,15 +61,7 @@ class SasTokenProviderImpl {
74
61
  * @param audience - The audience for which the token is desired.
75
62
  */
76
63
  async getToken(audience) {
77
- if (coreAuth.isNamedKeyCredential(this._credential)) {
78
- return createToken(this._credential.name, this._credential.key, Math.floor(Date.now() / 1000) + 3600, audience);
79
- }
80
- else {
81
- return {
82
- token: this._credential.signature,
83
- expiresOnTimestamp: 0,
84
- };
85
- }
64
+ return createToken(this._credential.sharedAccessKeyName, this._credential.sharedAccessKey, Math.floor(Date.now() / 1000) + 3600, audience);
86
65
  }
87
66
  }
88
67
  /**
@@ -324,6 +303,34 @@ function getTagsOrUndefined(value) {
324
303
  return result.split(",");
325
304
  }
326
305
 
306
+ // Copyright (c) Microsoft Corporation.
307
+ async function parseNotificationOutcome(bodyText) {
308
+ const xml = await coreXml.parseXML(bodyText, { includeRoot: true });
309
+ const outcome = xml.NotificationOutcome;
310
+ return {
311
+ success: getInteger(outcome.Success, "Success"),
312
+ failure: getInteger(outcome.Failure, "Failure"),
313
+ results: parseRegistrationResults(outcome.Results.RegistrationResult),
314
+ state: "DetailedStateAvailable",
315
+ };
316
+ }
317
+ function parseRegistrationResults(results) {
318
+ const registrationResults = [];
319
+ if (!isDefined(results)) {
320
+ return registrationResults;
321
+ }
322
+ const resultsArray = Array.isArray(results) ? results : [results];
323
+ for (const result of resultsArray) {
324
+ registrationResults.push({
325
+ applicationPlatform: getString(result.ApplicationPlatform, "ApplicationPlatform"),
326
+ registrationId: getString(result.RegistrationId, "RegistrationId"),
327
+ outcome: getString(result.Outcome, "Outcome"),
328
+ pnsHandle: getString(result.PnsHandle, "PnsHandle"),
329
+ });
330
+ }
331
+ return registrationResults;
332
+ }
333
+
327
334
  // Copyright (c) Microsoft Corporation.
328
335
  /**
329
336
  * Marker for atom metadata.
@@ -417,15 +424,14 @@ async function parseXMLError(bodyText) {
417
424
  }
418
425
 
419
426
  // Copyright (c) Microsoft Corporation.
420
- /**
421
- * @internal
422
- */
423
427
  function createRequest(endpoint, method, headers, options) {
424
428
  return coreRestPipeline.createPipelineRequest(Object.assign(Object.assign(Object.assign({}, options.tracingOptions), options.requestOptions), { url: endpoint.toString(), abortSignal: options.abortSignal, method,
425
429
  headers }));
426
430
  }
427
431
  /**
428
- * @internal
432
+ * Parses the HTTP response and creates a NotificationHubsResponse with header information from the operation.
433
+ * @param response - The HTTP response used to populate the result.
434
+ * @returns A NotificationHubsResponse with header information from the operation.
429
435
  */
430
436
  function parseNotificationResponse(response) {
431
437
  const correlationId = response.headers.get("x-ms-correlation-request-id");
@@ -438,16 +444,32 @@ function parseNotificationResponse(response) {
438
444
  };
439
445
  }
440
446
  /**
441
- * @internal
447
+ * Parses the HTTP response and creates a NotificationHubsMessageResponse with results from the notification.
448
+ * @param response - The HTTP response used to populate the result.
449
+ * @returns A NotificationHubsMessageResponse with results from the notification.
442
450
  */
443
- function parseNotificationSendResponse(response) {
451
+ async function parseNotificationSendResponse(response) {
444
452
  const result = parseNotificationResponse(response);
445
453
  let notificationId;
446
454
  if (result.location) {
447
455
  const locationUrl = new URL(result.location);
448
456
  notificationId = locationUrl.pathname.split("/")[3];
449
457
  }
450
- return Object.assign(Object.assign({}, result), { notificationId });
458
+ const requestUrl = new URL(response.request.url);
459
+ const isTestSend = requestUrl.searchParams.has("test");
460
+ const isDirectSend = requestUrl.searchParams.has("direct");
461
+ // Only broadcast/tag based sends are supported for test send
462
+ const responseBody = response.bodyAsText;
463
+ if (isTestSend && !isDirectSend && isDefined(responseBody)) {
464
+ const outcome = await parseNotificationOutcome(responseBody);
465
+ return Object.assign(Object.assign(Object.assign({}, result), outcome), { notificationId });
466
+ }
467
+ else {
468
+ return createDefaultResponse(result, notificationId);
469
+ }
470
+ }
471
+ function createDefaultResponse(response, notificationId) {
472
+ return Object.assign(Object.assign({}, response), { notificationId, success: 0, failure: 0, results: [], state: "Enqueued" });
451
473
  }
452
474
  /**
453
475
  * Sends a request through the client context.
@@ -652,20 +674,6 @@ const registrationDescriptionParser = {
652
674
  createGcmTemplateRegistrationDescription(rawRegistrationDescription) {
653
675
  return Object.assign(Object.assign(Object.assign({}, this.createGcmRegistrationDescription(rawRegistrationDescription)), createTemplateRegistrationDescription(rawRegistrationDescription)), { type: "GcmTemplate" });
654
676
  },
655
- /**
656
- * @internal
657
- * Creates an FCM registration description from incoming XML property bag.
658
- */
659
- createFcmRegistrationDescription(rawRegistrationDescription) {
660
- return Object.assign(Object.assign({ fcmRegistrationId: getString(rawRegistrationDescription["FcmRegistrationId"], "fcmRegistrationId") }, createRegistrationDescription(rawRegistrationDescription)), { type: "Fcm" });
661
- },
662
- /**
663
- * @internal
664
- * Creates an FCM template registration description from incoming XML property bag.
665
- */
666
- createFcmTemplateRegistrationDescription(rawRegistrationDescription) {
667
- return Object.assign(Object.assign(Object.assign({}, this.createFcmRegistrationDescription(rawRegistrationDescription)), createTemplateRegistrationDescription(rawRegistrationDescription)), { type: "FcmTemplate" });
668
- },
669
677
  /**
670
678
  * @internal
671
679
  * Creates a Windows Phone registration description from incoming XML property bag.
@@ -823,20 +831,6 @@ const registrationDescriptionSerializer = {
823
831
  serializeGcmTemplateRegistrationDescription(description) {
824
832
  return Object.assign(Object.assign({}, this.serializeGcmRegistrationDescription(description)), serializeTemplateRegistrationDescription(description));
825
833
  },
826
- /**
827
- * @internal
828
- * Serializes an existing FCM registration description to an object for serialization.
829
- */
830
- serializeFcmRegistrationDescription(description) {
831
- return Object.assign(Object.assign({}, serializeRegistrationDescription(description)), { FcmRegistrationId: description.fcmRegistrationId });
832
- },
833
- /**
834
- * @internal
835
- * Serializes an existing FCM template registration description to an object for serialization.
836
- */
837
- serializeFcmTemplateRegistrationDescription(description) {
838
- return Object.assign(Object.assign({}, this.serializeFcmRegistrationDescription(description)), serializeTemplateRegistrationDescription(description));
839
- },
840
834
  /**
841
835
  * @internal
842
836
  * @deprecated Windows Phone is no longer supported.
@@ -1097,6 +1091,9 @@ async function parseNotificationHubJobEntry(bodyText) {
1097
1091
  async function parseNotificationHubJobFeed(bodyText) {
1098
1092
  const xml = await coreXml.parseXML(bodyText, { includeRoot: true });
1099
1093
  const results = [];
1094
+ if (!isDefined(xml.feed.entry)) {
1095
+ return results;
1096
+ }
1100
1097
  for (const item of xml.feed.entry) {
1101
1098
  results.push(createNotificationHubJob(item.content.NotificationHubJob));
1102
1099
  }
@@ -1514,7 +1511,7 @@ function sendNotificationPayload(context, notification, method, pushHandle, tags
1514
1511
  const endpoint = context.requestUrl();
1515
1512
  endpoint.pathname += "/messages/";
1516
1513
  if (options.enableTestSend) {
1517
- endpoint.searchParams.append("debug", "true");
1514
+ endpoint.searchParams.append("test", "true");
1518
1515
  }
1519
1516
  const headers = await context.createHeaders(method);
1520
1517
  if (notification.headers) {
@@ -1572,8 +1569,7 @@ function sendBroadcastNotification(context, notification, options = {}) {
1572
1569
  * @param context - The Notification Hubs client.
1573
1570
  * @param pushHandle - The push handle which is the unique identifier for the device.
1574
1571
  * @param notification - The notification to send to the device.
1575
- * @param options - Configuration options for the direct send operation which can contain custom headers
1576
- * which may include APNs specific such as apns-topic or for WNS, X-WNS-TYPE.
1572
+ * @param options - The options for sending a direct notification.
1577
1573
  * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
1578
1574
  */
1579
1575
  function sendDirectNotification(context, pushHandle, notification, options = {}) {
@@ -1776,8 +1772,7 @@ class NotificationHubsServiceClient {
1776
1772
  * Sends a direct push notification to a device with the given push handle.
1777
1773
  * @param pushHandle - The push handle which is the unique identifier for the device.
1778
1774
  * @param notification - The notification to send to the device.
1779
- * @param options - Configuration options for the direct send operation which can contain custom headers
1780
- * which may include APNs specific such as apns-topic or for WNS, X-WNS-TYPE.
1775
+ * @param options - The options for sending a direct notification.
1781
1776
  * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
1782
1777
  */
1783
1778
  sendDirectNotification(pushHandle, notification, options = {}) {
@@ -1916,7 +1911,7 @@ function createBaiduInstallation(installation) {
1916
1911
  * @param installation - A partial installation used to create the Firebase Legacy HTTP installation.
1917
1912
  * @returns The newly created Baidu installation.
1918
1913
  */
1919
- function createFirebaseLegacyInstallation(installation) {
1914
+ function createFcmLegacyInstallation(installation) {
1920
1915
  return Object.assign(Object.assign({}, installation), { platform: "gcm" });
1921
1916
  }
1922
1917
  /**
@@ -1974,7 +1969,7 @@ function createBrowserNotification(notification) {
1974
1969
  * @param notification - A partial message used to create a message for Firebase.
1975
1970
  * @returns A newly created Firebase.
1976
1971
  */
1977
- function createFirebaseLegacyNotification(notification) {
1972
+ function createFcmLegacyNotification(notification) {
1978
1973
  return Object.assign(Object.assign({}, notification), { platform: "gcm", contentType: JSON_CONTENT_TYPE });
1979
1974
  }
1980
1975
  /**
@@ -2088,7 +2083,7 @@ function buildAppleNativeMessage(nativeMessage, additionalProperties) {
2088
2083
  headers: headers,
2089
2084
  });
2090
2085
  }
2091
- function buildFirebaseLegacyNativePayload(nativeNotification) {
2086
+ function buildFcmLegacyNativePayload(nativeNotification) {
2092
2087
  if (!isDefined(nativeNotification)) {
2093
2088
  return undefined;
2094
2089
  }
@@ -2115,9 +2110,9 @@ function buildFirebaseLegacyNativePayload(nativeNotification) {
2115
2110
  return notification;
2116
2111
  }
2117
2112
  /**
2118
- * Creates a FirebaseLegacyNotification from a native Firebase payload.
2113
+ * Creates a FcmLegacyNotification from a native Firebase payload.
2119
2114
  * @param nativeMessage - The native message payload to send to Notification Hubs.
2120
- * @returns The FirebaseLegacyNotification to send to Notification Hubs.
2115
+ * @returns The FcmLegacyNotification to send to Notification Hubs.
2121
2116
  */
2122
2117
  function buildFirebaseLegacyNativeMessage(nativeMessage) {
2123
2118
  const jsonMessage = {
@@ -2132,9 +2127,9 @@ function buildFirebaseLegacyNativeMessage(nativeMessage) {
2132
2127
  restricted_package_name: nativeMessage.restrictedPackageName,
2133
2128
  dry_run: nativeMessage.dryRun,
2134
2129
  data: nativeMessage.data,
2135
- notification: buildFirebaseLegacyNativePayload(nativeMessage.notification),
2130
+ notification: buildFcmLegacyNativePayload(nativeMessage.notification),
2136
2131
  };
2137
- return createFirebaseLegacyNotification({
2132
+ return createFcmLegacyNotification({
2138
2133
  body: JSON.stringify(jsonMessage),
2139
2134
  });
2140
2135
  }
@@ -2270,57 +2265,21 @@ function createBrowserTemplateRegistrationDescription(description) {
2270
2265
  return Object.assign(Object.assign({}, description), { type: "BrowserTemplate" });
2271
2266
  }
2272
2267
  /**
2273
- * @deprecated Use createFcmRegistrationDescription instead.
2274
- * Creates a GCM registration description.
2268
+ * Creates a Firebase Legacy registration description.
2275
2269
  * @param description - A partial GCM registration description.
2276
2270
  * @returns A created GCM registration description.
2277
2271
  */
2278
- function createGcmRegistrationDescription(description) {
2272
+ function createFcmLegacyRegistrationDescription(description) {
2279
2273
  return Object.assign(Object.assign({}, description), { type: "Gcm" });
2280
2274
  }
2281
2275
  /**
2282
- * @deprecated Use createFcmTemplateRegistrationDescription instead.
2283
2276
  * Creates a GCM template registration description.
2284
2277
  * @param description - A partial GCM template registration description.
2285
2278
  * @returns A created GCM template registration description.
2286
2279
  */
2287
- function createGcmTemplateRegistrationDescription(description) {
2280
+ function createFcmLegacyTemplateRegistrationDescription(description) {
2288
2281
  return Object.assign(Object.assign({}, description), { type: "GcmTemplate" });
2289
2282
  }
2290
- /**
2291
- * Creates an FCM registration description.
2292
- * @param description - A partial FCM registration description.
2293
- * @returns A created FCM registration description.
2294
- */
2295
- function createFcmRegistrationDescription(description) {
2296
- return Object.assign(Object.assign({}, description), { type: "Fcm" });
2297
- }
2298
- /**
2299
- * Creates an FCM template registration description.
2300
- * @param description - A partial FCM template registration description.
2301
- * @returns A created FCM template registration description.
2302
- */
2303
- function createFcmTemplateRegistrationDescription(description) {
2304
- return Object.assign(Object.assign({}, description), { type: "FcmTemplate" });
2305
- }
2306
- /**
2307
- * @deprecated Windows Phone is no longer supported.
2308
- * Creates an MPNS registration description.
2309
- * @param description - A partial MPNS registration description.
2310
- * @returns A created MPNS registration description.
2311
- */
2312
- function createMpnsRegistrationDescription(description) {
2313
- return Object.assign(Object.assign({}, description), { type: "Mpns" });
2314
- }
2315
- /**
2316
- * @deprecated Windows Phone is no longer supported.
2317
- * Creates an MPNS template registration description.
2318
- * @param description - A partial MPNS template registration description.
2319
- * @returns A created MPNS template registration description.
2320
- */
2321
- function createMpnsTemplateRegistrationDescription(description) {
2322
- return Object.assign(Object.assign({}, description), { type: "MpnsTemplate" });
2323
- }
2324
2283
  /**
2325
2284
  * Creates a Windows registration description.
2326
2285
  * @param description - A partial Windows registration description.
@@ -2360,14 +2319,10 @@ exports.createBrowserInstallation = createBrowserInstallation;
2360
2319
  exports.createBrowserNotification = createBrowserNotification;
2361
2320
  exports.createBrowserRegistrationDescription = createBrowserRegistrationDescription;
2362
2321
  exports.createBrowserTemplateRegistrationDescription = createBrowserTemplateRegistrationDescription;
2363
- exports.createFcmRegistrationDescription = createFcmRegistrationDescription;
2364
- exports.createFcmTemplateRegistrationDescription = createFcmTemplateRegistrationDescription;
2365
- exports.createFirebaseLegacyInstallation = createFirebaseLegacyInstallation;
2366
- exports.createFirebaseLegacyNotification = createFirebaseLegacyNotification;
2367
- exports.createGcmRegistrationDescription = createGcmRegistrationDescription;
2368
- exports.createGcmTemplateRegistrationDescription = createGcmTemplateRegistrationDescription;
2369
- exports.createMpnsRegistrationDescription = createMpnsRegistrationDescription;
2370
- exports.createMpnsTemplateRegistrationDescription = createMpnsTemplateRegistrationDescription;
2322
+ exports.createFcmLegacyInstallation = createFcmLegacyInstallation;
2323
+ exports.createFcmLegacyNotification = createFcmLegacyNotification;
2324
+ exports.createFcmLegacyRegistrationDescription = createFcmLegacyRegistrationDescription;
2325
+ exports.createFcmLegacyTemplateRegistrationDescription = createFcmLegacyTemplateRegistrationDescription;
2371
2326
  exports.createTemplateNotification = createTemplateNotification;
2372
2327
  exports.createWindowsBadgeNotification = createWindowsBadgeNotification;
2373
2328
  exports.createWindowsInstallation = createWindowsInstallation;