@azure/notification-hubs 1.0.2-alpha.20230330.2 → 1.0.2-alpha.20230418.1
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 +30 -16
- package/dist/index.cjs.map +1 -1
- package/dist-esm/src/api/internal/_listRegistrations.js +12 -5
- package/dist-esm/src/api/internal/_listRegistrations.js.map +1 -1
- package/dist-esm/src/api/listRegistrationsByTag.js +12 -5
- package/dist-esm/src/api/listRegistrationsByTag.js.map +1 -1
- package/dist-esm/src/auth/sasTokenProvider.js +6 -6
- package/dist-esm/src/auth/sasTokenProvider.js.map +1 -1
- package/package.json +3 -3
- package/types/src/auth/connectionStringUtils.d.ts +1 -1
- package/types/src/auth/connectionStringUtils.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 +2 -2
- package/types/src/models/notification.d.ts.map +1 -1
- package/types/src/models/notificationBodyBuilder.d.ts +1 -1
- package/types/src/models/notificationBodyBuilder.d.ts.map +1 -1
- package/types/src/models/notificationDetails.d.ts +1 -1
- package/types/src/models/notificationDetails.d.ts.map +1 -1
- package/types/src/models/notificationHubJob.d.ts +3 -3
- package/types/src/models/notificationHubJob.d.ts.map +1 -1
- package/types/src/models/registration.d.ts +3 -3
- package/types/src/models/registration.d.ts.map +1 -1
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
|
@@ -45,6 +45,12 @@ function createSasTokenProvider(data) {
|
|
|
45
45
|
* @internal
|
|
46
46
|
*/
|
|
47
47
|
class SasTokenProviderImpl {
|
|
48
|
+
/**
|
|
49
|
+
* Property used to distinguish TokenProvider from TokenCredential.
|
|
50
|
+
*/
|
|
51
|
+
get isSasTokenProvider() {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
48
54
|
/**
|
|
49
55
|
* Initializes a new instance of SasTokenProvider
|
|
50
56
|
* @param credential - The source `NamedKeyCredential` or `SASCredential`.
|
|
@@ -52,12 +58,6 @@ class SasTokenProviderImpl {
|
|
|
52
58
|
constructor(credential) {
|
|
53
59
|
this._credential = credential;
|
|
54
60
|
}
|
|
55
|
-
/**
|
|
56
|
-
* Property used to distinguish TokenProvider from TokenCredential.
|
|
57
|
-
*/
|
|
58
|
-
get isSasTokenProvider() {
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
61
|
/**
|
|
62
62
|
* Gets the sas token for the specified audience
|
|
63
63
|
* @param audience - The audience for which the token is desired.
|
|
@@ -1441,17 +1441,24 @@ function listNotificationHubJobs(context, options = {}) {
|
|
|
1441
1441
|
// Copyright (c) Microsoft Corporation.
|
|
1442
1442
|
function listRegistrationsAll(context, options) {
|
|
1443
1443
|
return tslib.__asyncGenerator(this, arguments, function* listRegistrationsAll_1() {
|
|
1444
|
-
var e_1,
|
|
1444
|
+
var _a, e_1, _b, _c;
|
|
1445
1445
|
try {
|
|
1446
|
-
for (var
|
|
1447
|
-
|
|
1448
|
-
|
|
1446
|
+
for (var _d = true, _e = tslib.__asyncValues(listRegistrationPagingPage(context, options)), _f; _f = yield tslib.__await(_e.next()), _a = _f.done, !_a;) {
|
|
1447
|
+
_c = _f.value;
|
|
1448
|
+
_d = false;
|
|
1449
|
+
try {
|
|
1450
|
+
const page = _c;
|
|
1451
|
+
yield tslib.__await(yield* tslib.__asyncDelegator(tslib.__asyncValues(page)));
|
|
1452
|
+
}
|
|
1453
|
+
finally {
|
|
1454
|
+
_d = true;
|
|
1455
|
+
}
|
|
1449
1456
|
}
|
|
1450
1457
|
}
|
|
1451
1458
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1452
1459
|
finally {
|
|
1453
1460
|
try {
|
|
1454
|
-
if (
|
|
1461
|
+
if (!_d && !_a && (_b = _e.return)) yield tslib.__await(_b.call(_e));
|
|
1455
1462
|
}
|
|
1456
1463
|
finally { if (e_1) throw e_1.error; }
|
|
1457
1464
|
}
|
|
@@ -1613,17 +1620,24 @@ function listRegistrationsByTag(context, tag, options = {}) {
|
|
|
1613
1620
|
}
|
|
1614
1621
|
function listRegistrationsByTagAll(context, tag, options) {
|
|
1615
1622
|
return tslib.__asyncGenerator(this, arguments, function* listRegistrationsByTagAll_1() {
|
|
1616
|
-
var e_1,
|
|
1623
|
+
var _a, e_1, _b, _c;
|
|
1617
1624
|
try {
|
|
1618
|
-
for (var
|
|
1619
|
-
|
|
1620
|
-
|
|
1625
|
+
for (var _d = true, _e = tslib.__asyncValues(listRegistrationsByTagPagingPage(context, tag, options)), _f; _f = yield tslib.__await(_e.next()), _a = _f.done, !_a;) {
|
|
1626
|
+
_c = _f.value;
|
|
1627
|
+
_d = false;
|
|
1628
|
+
try {
|
|
1629
|
+
const page = _c;
|
|
1630
|
+
yield tslib.__await(yield* tslib.__asyncDelegator(tslib.__asyncValues(page)));
|
|
1631
|
+
}
|
|
1632
|
+
finally {
|
|
1633
|
+
_d = true;
|
|
1634
|
+
}
|
|
1621
1635
|
}
|
|
1622
1636
|
}
|
|
1623
1637
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1624
1638
|
finally {
|
|
1625
1639
|
try {
|
|
1626
|
-
if (
|
|
1640
|
+
if (!_d && !_a && (_b = _e.return)) yield tslib.__await(_b.call(_e));
|
|
1627
1641
|
}
|
|
1628
1642
|
finally { if (e_1) throw e_1.error; }
|
|
1629
1643
|
}
|