@azure/notification-hubs 1.0.0-beta.3 → 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.cjs +76 -118
- package/dist/index.cjs.map +1 -1
- package/dist-esm/src/auth/hmacSha256.browser.js +1 -0
- package/dist-esm/src/auth/hmacSha256.browser.js.map +1 -1
- package/dist-esm/src/auth/sasTokenProvider.js +2 -23
- package/dist-esm/src/auth/sasTokenProvider.js.map +1 -1
- package/dist-esm/src/client/cancelScheduledNotification.js.map +1 -1
- package/dist-esm/src/client/createOrUpdateInstallation.js.map +1 -1
- package/dist-esm/src/client/deleteInstallation.js.map +1 -1
- package/dist-esm/src/client/deleteRegistration.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/_scheduleNotificationPayload.js.map +1 -1
- package/dist-esm/src/client/internal/_sendNotificationPayload.js +1 -1
- package/dist-esm/src/client/internal/_sendNotificationPayload.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/updateInstallation.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 -1
- package/dist-esm/src/utils/constants.js.map +1 -1
- package/package.json +4 -4
- 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/auth/hmacSha256.browser.d.ts +1 -0
- package/types/src/auth/hmacSha256.browser.d.ts.map +1 -1
- package/types/src/auth/sasTokenProvider.d.ts +28 -8
- package/types/src/auth/sasTokenProvider.d.ts.map +1 -1
- 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/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/index.d.ts +0 -1
- 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/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/updateInstallation.d.ts +1 -1
- package/types/src/client/updateInstallation.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/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/
|
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.
|
|
14
|
+
const SDK_VERSION = "1.0.0-beta.4";
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
|
|
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.
|
|
@@ -565,6 +587,9 @@ const registrationDescriptionParser = {
|
|
|
565
587
|
async parseRegistrationFeed(bodyText) {
|
|
566
588
|
const xml = await coreXml.parseXML(bodyText, { includeRoot: true });
|
|
567
589
|
const results = [];
|
|
590
|
+
if (!isDefined(xml.feed.entry)) {
|
|
591
|
+
return results;
|
|
592
|
+
}
|
|
568
593
|
for (const entry of xml.feed.entry) {
|
|
569
594
|
delete entry.content["$"];
|
|
570
595
|
const keyName = Object.keys(entry.content)[0];
|
|
@@ -649,20 +674,6 @@ const registrationDescriptionParser = {
|
|
|
649
674
|
createGcmTemplateRegistrationDescription(rawRegistrationDescription) {
|
|
650
675
|
return Object.assign(Object.assign(Object.assign({}, this.createGcmRegistrationDescription(rawRegistrationDescription)), createTemplateRegistrationDescription(rawRegistrationDescription)), { type: "GcmTemplate" });
|
|
651
676
|
},
|
|
652
|
-
/**
|
|
653
|
-
* @internal
|
|
654
|
-
* Creates an FCM registration description from incoming XML property bag.
|
|
655
|
-
*/
|
|
656
|
-
createFcmRegistrationDescription(rawRegistrationDescription) {
|
|
657
|
-
return Object.assign(Object.assign({ fcmRegistrationId: getString(rawRegistrationDescription["FcmRegistrationId"], "fcmRegistrationId") }, createRegistrationDescription(rawRegistrationDescription)), { type: "Fcm" });
|
|
658
|
-
},
|
|
659
|
-
/**
|
|
660
|
-
* @internal
|
|
661
|
-
* Creates an FCM template registration description from incoming XML property bag.
|
|
662
|
-
*/
|
|
663
|
-
createFcmTemplateRegistrationDescription(rawRegistrationDescription) {
|
|
664
|
-
return Object.assign(Object.assign(Object.assign({}, this.createFcmRegistrationDescription(rawRegistrationDescription)), createTemplateRegistrationDescription(rawRegistrationDescription)), { type: "FcmTemplate" });
|
|
665
|
-
},
|
|
666
677
|
/**
|
|
667
678
|
* @internal
|
|
668
679
|
* Creates a Windows Phone registration description from incoming XML property bag.
|
|
@@ -820,20 +831,6 @@ const registrationDescriptionSerializer = {
|
|
|
820
831
|
serializeGcmTemplateRegistrationDescription(description) {
|
|
821
832
|
return Object.assign(Object.assign({}, this.serializeGcmRegistrationDescription(description)), serializeTemplateRegistrationDescription(description));
|
|
822
833
|
},
|
|
823
|
-
/**
|
|
824
|
-
* @internal
|
|
825
|
-
* Serializes an existing FCM registration description to an object for serialization.
|
|
826
|
-
*/
|
|
827
|
-
serializeFcmRegistrationDescription(description) {
|
|
828
|
-
return Object.assign(Object.assign({}, serializeRegistrationDescription(description)), { FcmRegistrationId: description.fcmRegistrationId });
|
|
829
|
-
},
|
|
830
|
-
/**
|
|
831
|
-
* @internal
|
|
832
|
-
* Serializes an existing FCM template registration description to an object for serialization.
|
|
833
|
-
*/
|
|
834
|
-
serializeFcmTemplateRegistrationDescription(description) {
|
|
835
|
-
return Object.assign(Object.assign({}, this.serializeFcmRegistrationDescription(description)), serializeTemplateRegistrationDescription(description));
|
|
836
|
-
},
|
|
837
834
|
/**
|
|
838
835
|
* @internal
|
|
839
836
|
* @deprecated Windows Phone is no longer supported.
|
|
@@ -1094,6 +1091,9 @@ async function parseNotificationHubJobEntry(bodyText) {
|
|
|
1094
1091
|
async function parseNotificationHubJobFeed(bodyText) {
|
|
1095
1092
|
const xml = await coreXml.parseXML(bodyText, { includeRoot: true });
|
|
1096
1093
|
const results = [];
|
|
1094
|
+
if (!isDefined(xml.feed.entry)) {
|
|
1095
|
+
return results;
|
|
1096
|
+
}
|
|
1097
1097
|
for (const item of xml.feed.entry) {
|
|
1098
1098
|
results.push(createNotificationHubJob(item.content.NotificationHubJob));
|
|
1099
1099
|
}
|
|
@@ -1511,7 +1511,7 @@ function sendNotificationPayload(context, notification, method, pushHandle, tags
|
|
|
1511
1511
|
const endpoint = context.requestUrl();
|
|
1512
1512
|
endpoint.pathname += "/messages/";
|
|
1513
1513
|
if (options.enableTestSend) {
|
|
1514
|
-
endpoint.searchParams.append("
|
|
1514
|
+
endpoint.searchParams.append("test", "true");
|
|
1515
1515
|
}
|
|
1516
1516
|
const headers = await context.createHeaders(method);
|
|
1517
1517
|
if (notification.headers) {
|
|
@@ -1569,8 +1569,7 @@ function sendBroadcastNotification(context, notification, options = {}) {
|
|
|
1569
1569
|
* @param context - The Notification Hubs client.
|
|
1570
1570
|
* @param pushHandle - The push handle which is the unique identifier for the device.
|
|
1571
1571
|
* @param notification - The notification to send to the device.
|
|
1572
|
-
* @param options -
|
|
1573
|
-
* 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.
|
|
1574
1573
|
* @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
|
|
1575
1574
|
*/
|
|
1576
1575
|
function sendDirectNotification(context, pushHandle, notification, options = {}) {
|
|
@@ -1773,8 +1772,7 @@ class NotificationHubsServiceClient {
|
|
|
1773
1772
|
* Sends a direct push notification to a device with the given push handle.
|
|
1774
1773
|
* @param pushHandle - The push handle which is the unique identifier for the device.
|
|
1775
1774
|
* @param notification - The notification to send to the device.
|
|
1776
|
-
* @param options -
|
|
1777
|
-
* 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.
|
|
1778
1776
|
* @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
|
|
1779
1777
|
*/
|
|
1780
1778
|
sendDirectNotification(pushHandle, notification, options = {}) {
|
|
@@ -1913,7 +1911,7 @@ function createBaiduInstallation(installation) {
|
|
|
1913
1911
|
* @param installation - A partial installation used to create the Firebase Legacy HTTP installation.
|
|
1914
1912
|
* @returns The newly created Baidu installation.
|
|
1915
1913
|
*/
|
|
1916
|
-
function
|
|
1914
|
+
function createFcmLegacyInstallation(installation) {
|
|
1917
1915
|
return Object.assign(Object.assign({}, installation), { platform: "gcm" });
|
|
1918
1916
|
}
|
|
1919
1917
|
/**
|
|
@@ -1971,7 +1969,7 @@ function createBrowserNotification(notification) {
|
|
|
1971
1969
|
* @param notification - A partial message used to create a message for Firebase.
|
|
1972
1970
|
* @returns A newly created Firebase.
|
|
1973
1971
|
*/
|
|
1974
|
-
function
|
|
1972
|
+
function createFcmLegacyNotification(notification) {
|
|
1975
1973
|
return Object.assign(Object.assign({}, notification), { platform: "gcm", contentType: JSON_CONTENT_TYPE });
|
|
1976
1974
|
}
|
|
1977
1975
|
/**
|
|
@@ -2085,7 +2083,7 @@ function buildAppleNativeMessage(nativeMessage, additionalProperties) {
|
|
|
2085
2083
|
headers: headers,
|
|
2086
2084
|
});
|
|
2087
2085
|
}
|
|
2088
|
-
function
|
|
2086
|
+
function buildFcmLegacyNativePayload(nativeNotification) {
|
|
2089
2087
|
if (!isDefined(nativeNotification)) {
|
|
2090
2088
|
return undefined;
|
|
2091
2089
|
}
|
|
@@ -2112,9 +2110,9 @@ function buildFirebaseLegacyNativePayload(nativeNotification) {
|
|
|
2112
2110
|
return notification;
|
|
2113
2111
|
}
|
|
2114
2112
|
/**
|
|
2115
|
-
* Creates a
|
|
2113
|
+
* Creates a FcmLegacyNotification from a native Firebase payload.
|
|
2116
2114
|
* @param nativeMessage - The native message payload to send to Notification Hubs.
|
|
2117
|
-
* @returns The
|
|
2115
|
+
* @returns The FcmLegacyNotification to send to Notification Hubs.
|
|
2118
2116
|
*/
|
|
2119
2117
|
function buildFirebaseLegacyNativeMessage(nativeMessage) {
|
|
2120
2118
|
const jsonMessage = {
|
|
@@ -2129,9 +2127,9 @@ function buildFirebaseLegacyNativeMessage(nativeMessage) {
|
|
|
2129
2127
|
restricted_package_name: nativeMessage.restrictedPackageName,
|
|
2130
2128
|
dry_run: nativeMessage.dryRun,
|
|
2131
2129
|
data: nativeMessage.data,
|
|
2132
|
-
notification:
|
|
2130
|
+
notification: buildFcmLegacyNativePayload(nativeMessage.notification),
|
|
2133
2131
|
};
|
|
2134
|
-
return
|
|
2132
|
+
return createFcmLegacyNotification({
|
|
2135
2133
|
body: JSON.stringify(jsonMessage),
|
|
2136
2134
|
});
|
|
2137
2135
|
}
|
|
@@ -2267,57 +2265,21 @@ function createBrowserTemplateRegistrationDescription(description) {
|
|
|
2267
2265
|
return Object.assign(Object.assign({}, description), { type: "BrowserTemplate" });
|
|
2268
2266
|
}
|
|
2269
2267
|
/**
|
|
2270
|
-
*
|
|
2271
|
-
* Creates a GCM registration description.
|
|
2268
|
+
* Creates a Firebase Legacy registration description.
|
|
2272
2269
|
* @param description - A partial GCM registration description.
|
|
2273
2270
|
* @returns A created GCM registration description.
|
|
2274
2271
|
*/
|
|
2275
|
-
function
|
|
2272
|
+
function createFcmLegacyRegistrationDescription(description) {
|
|
2276
2273
|
return Object.assign(Object.assign({}, description), { type: "Gcm" });
|
|
2277
2274
|
}
|
|
2278
2275
|
/**
|
|
2279
|
-
* @deprecated Use createFcmTemplateRegistrationDescription instead.
|
|
2280
2276
|
* Creates a GCM template registration description.
|
|
2281
2277
|
* @param description - A partial GCM template registration description.
|
|
2282
2278
|
* @returns A created GCM template registration description.
|
|
2283
2279
|
*/
|
|
2284
|
-
function
|
|
2280
|
+
function createFcmLegacyTemplateRegistrationDescription(description) {
|
|
2285
2281
|
return Object.assign(Object.assign({}, description), { type: "GcmTemplate" });
|
|
2286
2282
|
}
|
|
2287
|
-
/**
|
|
2288
|
-
* Creates an FCM registration description.
|
|
2289
|
-
* @param description - A partial FCM registration description.
|
|
2290
|
-
* @returns A created FCM registration description.
|
|
2291
|
-
*/
|
|
2292
|
-
function createFcmRegistrationDescription(description) {
|
|
2293
|
-
return Object.assign(Object.assign({}, description), { type: "Fcm" });
|
|
2294
|
-
}
|
|
2295
|
-
/**
|
|
2296
|
-
* Creates an FCM template registration description.
|
|
2297
|
-
* @param description - A partial FCM template registration description.
|
|
2298
|
-
* @returns A created FCM template registration description.
|
|
2299
|
-
*/
|
|
2300
|
-
function createFcmTemplateRegistrationDescription(description) {
|
|
2301
|
-
return Object.assign(Object.assign({}, description), { type: "FcmTemplate" });
|
|
2302
|
-
}
|
|
2303
|
-
/**
|
|
2304
|
-
* @deprecated Windows Phone is no longer supported.
|
|
2305
|
-
* Creates an MPNS registration description.
|
|
2306
|
-
* @param description - A partial MPNS registration description.
|
|
2307
|
-
* @returns A created MPNS registration description.
|
|
2308
|
-
*/
|
|
2309
|
-
function createMpnsRegistrationDescription(description) {
|
|
2310
|
-
return Object.assign(Object.assign({}, description), { type: "Mpns" });
|
|
2311
|
-
}
|
|
2312
|
-
/**
|
|
2313
|
-
* @deprecated Windows Phone is no longer supported.
|
|
2314
|
-
* Creates an MPNS template registration description.
|
|
2315
|
-
* @param description - A partial MPNS template registration description.
|
|
2316
|
-
* @returns A created MPNS template registration description.
|
|
2317
|
-
*/
|
|
2318
|
-
function createMpnsTemplateRegistrationDescription(description) {
|
|
2319
|
-
return Object.assign(Object.assign({}, description), { type: "MpnsTemplate" });
|
|
2320
|
-
}
|
|
2321
2283
|
/**
|
|
2322
2284
|
* Creates a Windows registration description.
|
|
2323
2285
|
* @param description - A partial Windows registration description.
|
|
@@ -2357,14 +2319,10 @@ exports.createBrowserInstallation = createBrowserInstallation;
|
|
|
2357
2319
|
exports.createBrowserNotification = createBrowserNotification;
|
|
2358
2320
|
exports.createBrowserRegistrationDescription = createBrowserRegistrationDescription;
|
|
2359
2321
|
exports.createBrowserTemplateRegistrationDescription = createBrowserTemplateRegistrationDescription;
|
|
2360
|
-
exports.
|
|
2361
|
-
exports.
|
|
2362
|
-
exports.
|
|
2363
|
-
exports.
|
|
2364
|
-
exports.createGcmRegistrationDescription = createGcmRegistrationDescription;
|
|
2365
|
-
exports.createGcmTemplateRegistrationDescription = createGcmTemplateRegistrationDescription;
|
|
2366
|
-
exports.createMpnsRegistrationDescription = createMpnsRegistrationDescription;
|
|
2367
|
-
exports.createMpnsTemplateRegistrationDescription = createMpnsTemplateRegistrationDescription;
|
|
2322
|
+
exports.createFcmLegacyInstallation = createFcmLegacyInstallation;
|
|
2323
|
+
exports.createFcmLegacyNotification = createFcmLegacyNotification;
|
|
2324
|
+
exports.createFcmLegacyRegistrationDescription = createFcmLegacyRegistrationDescription;
|
|
2325
|
+
exports.createFcmLegacyTemplateRegistrationDescription = createFcmLegacyTemplateRegistrationDescription;
|
|
2368
2326
|
exports.createTemplateNotification = createTemplateNotification;
|
|
2369
2327
|
exports.createWindowsBadgeNotification = createWindowsBadgeNotification;
|
|
2370
2328
|
exports.createWindowsInstallation = createWindowsInstallation;
|