@azure/notification-hubs 1.0.1 → 1.0.2-alpha.20230406.2
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 +13 -11
- package/dist/index.cjs +2 -3
- package/dist/index.cjs.map +1 -1
- package/dist-esm/src/api/sendNotification.js +2 -2
- package/dist-esm/src/api/sendNotification.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 +6 -8
package/README.md
CHANGED
|
@@ -52,9 +52,9 @@ Once created, the Notification Hub can be configured using the [Azure Portal or
|
|
|
52
52
|
This SDK for JavaScript offers two ways of interacting with Azure Notification Hubs, either through the class-based approach, or with a modular design approach. The class-based approach is consistent across all packages to create a client and then interact with the methods on the client.
|
|
53
53
|
|
|
54
54
|
```typescript
|
|
55
|
-
import {
|
|
55
|
+
import {
|
|
56
56
|
NotificationHubsClient,
|
|
57
|
-
createAppleInstallation
|
|
57
|
+
createAppleInstallation
|
|
58
58
|
} from "@azure/notification-hubs";
|
|
59
59
|
|
|
60
60
|
const client = new NotificationHubsClient("<connection string>", "<hub name>");
|
|
@@ -68,9 +68,9 @@ const installation = createAppleInstallation({
|
|
|
68
68
|
const result = await client.createOrUpdateInstallation(installation);
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
-
The modular approach allows the developer to pick and choose which functions to import as each method is exposed individually. This approach uses subpath-exports with ES-Modules to expose the methods via direct imports. With the individual exports, this creates a better tree-shaking experience and smaller bundle sizes that the developer can take advantage of.
|
|
71
|
+
The modular approach allows the developer to pick and choose which functions to import as each method is exposed individually. This approach uses subpath-exports with ES-Modules to expose the methods via direct imports. With the individual exports, this creates a better tree-shaking experience and smaller bundle sizes that the developer can take advantage of.
|
|
72
72
|
|
|
73
|
-
Note that creating a client is exposed through the `"@azure/notification-hubs/api"` subpath and all client methods are exposed through the `"@azure/notification-hubs/api"` subpath. Each function exported takes the `client` as the first parameter and the rest of the parameters remain unchanged.
|
|
73
|
+
Note that creating a client is exposed through the `"@azure/notification-hubs/api"` subpath and all client methods are exposed through the `"@azure/notification-hubs/api"` subpath. Each function exported takes the `client` as the first parameter and the rest of the parameters remain unchanged.
|
|
74
74
|
|
|
75
75
|
The following subpaths are exposed:
|
|
76
76
|
|
|
@@ -293,10 +293,10 @@ registration = await client.updateRegistration(registration);
|
|
|
293
293
|
Using the modular approach, the code would be as follows:
|
|
294
294
|
|
|
295
295
|
```typescript
|
|
296
|
-
import {
|
|
297
|
-
createClientContext,
|
|
298
|
-
getRegistration,
|
|
299
|
-
updateRegistration
|
|
296
|
+
import {
|
|
297
|
+
createClientContext,
|
|
298
|
+
getRegistration,
|
|
299
|
+
updateRegistration
|
|
300
300
|
} from "@azure/notification-hubs/api";
|
|
301
301
|
|
|
302
302
|
const context = createClientContext("<connection string>", "<hub name>");
|
|
@@ -384,7 +384,7 @@ const result = await sendNotification(context, notification);
|
|
|
384
384
|
Notification Hubs can be used to send notifications to all registered devices per platform using broadcast send through the `sendNotification` method.
|
|
385
385
|
|
|
386
386
|
```typescript
|
|
387
|
-
import {
|
|
387
|
+
import {
|
|
388
388
|
NotificationHubsClient,
|
|
389
389
|
createAppleNotification,
|
|
390
390
|
} from "@azure/notification-hubs/api";
|
|
@@ -443,7 +443,7 @@ if (result.notificationId) {
|
|
|
443
443
|
|
|
444
444
|
#### Direct Send
|
|
445
445
|
|
|
446
|
-
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.
|
|
446
|
+
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.
|
|
447
447
|
|
|
448
448
|
```typescript
|
|
449
449
|
import {
|
|
@@ -663,9 +663,11 @@ React Native currently does not have support for [`URLSearchParams`] which is us
|
|
|
663
663
|
import 'url-search-params-polyfill';
|
|
664
664
|
```
|
|
665
665
|
|
|
666
|
+
We also need to provide polyfill for `TextEncoder` API and async iterator API. Please see our [React Native sample with Expo](https://github.com/Azure/azure-sdk-for-js/blob/main/samples/frameworks/react-native/appconfigBasic/README.md#add-polyfills) for more details.
|
|
667
|
+
|
|
666
668
|
### Diagnose Dropped Notifications
|
|
667
669
|
|
|
668
|
-
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).
|
|
670
|
+
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).
|
|
669
671
|
|
|
670
672
|
[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:
|
|
671
673
|
|
package/dist/index.cjs
CHANGED
|
@@ -10,11 +10,10 @@ var abortController = require('@azure/abort-controller');
|
|
|
10
10
|
var coreTracing = require('@azure/core-tracing');
|
|
11
11
|
var tslib = require('tslib');
|
|
12
12
|
var coreUtil = require('@azure/core-util');
|
|
13
|
-
var uuid = require('uuid');
|
|
14
13
|
|
|
15
14
|
// Copyright (c) Microsoft Corporation.
|
|
16
15
|
// Licensed under the MIT license.
|
|
17
|
-
const SDK_VERSION = "1.0.
|
|
16
|
+
const SDK_VERSION = "1.0.2";
|
|
18
17
|
const JSON_CONTENT_TYPE = "application/json;charset=utf-8";
|
|
19
18
|
const XML_CONTENT_TYPE = "application/xml";
|
|
20
19
|
const STREAM_CONTENT_TYPE = "application/octet-stream";
|
|
@@ -1754,7 +1753,7 @@ function sendNotification(context, notification, options = { enableTestSend: fal
|
|
|
1754
1753
|
// Check for direct batch send
|
|
1755
1754
|
if (isDirectSendNotificationOptions(options) && Array.isArray(options.deviceHandle)) {
|
|
1756
1755
|
endpoint.searchParams.append("direct", "true");
|
|
1757
|
-
const boundary = `nh-boundary-${
|
|
1756
|
+
const boundary = `nh-boundary-${coreUtil.randomUUID()}`;
|
|
1758
1757
|
contentType = `multipart/mixed; boundary = "${boundary}"`;
|
|
1759
1758
|
body = createMultipartDirectNotification(boundary, notification, options.deviceHandle);
|
|
1760
1759
|
}
|