Skip to content

Commit bb52e8c

Browse files
authored
Merge pull request #48 from OneSignal/api
Dependency Update
2 parents 4fa0399 + fdc41b6 commit bb52e8c

File tree

80 files changed

+4794
-310
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+4794
-310
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
3+
4+
## January 2023
5+
### `1.0.0-beta9` - 09/06/2023
6+
- Added User model endpoints
7+
- Limitations
8+
- Recommend using only in development and staging environments for Alpha releases.
9+
- Aliases will be available in a future release
10+
- Outcomes will be available in a future release
11+
- Users are deleted when the last subscription is removed
12+
- Known issues
13+
- User properties may not update when Subscriptions are transferred
14+
- Identity Verification
15+
- We will be introducing JWT in follow up Alpha or Beta release
16+
- Extra disabled subscriptions are created when switching Users in the SDK.
17+
318
## December 2022
419
### `1.0.0-beta8` - 11/14/2022
520
- Added Live Activity endpoints

DefaultApi.md

Lines changed: 1139 additions & 153 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,154 @@ const subscriptionId = '<subscription_id>'; // player id
440440
await api.endLiveActivity('<app_id>', '<activity_id>', subscriptionId);
441441
```
442442

443+
### Subscription types
444+
* iOSPush
445+
* AndroidPush
446+
* FireOSPush
447+
* ChromeExtensionPush
448+
* ChromePush
449+
* WindowsPush
450+
* SafariLegacyPush
451+
* FirefoxPush
452+
* macOSPush
453+
* HuaweiPush
454+
* SafariPush
455+
* Email
456+
* SMS
457+
458+
## Users
459+
### Creating a OneSignal User
460+
```js
461+
const user = new OneSignal.User();
462+
463+
const aliasLabel = '<alias_label>';
464+
const aliasId = '<alias_id>';
465+
const subscriptionToken = '<subscription_token>';
466+
467+
user.identity = {
468+
[aliasLabel]: aliasId,
469+
};
470+
471+
user.subscriptions = [
472+
{
473+
type: "iOSPush",
474+
token: subscriptionToken,
475+
}
476+
];
477+
478+
const createdUser = await api.createUser('<app_id>', user);
479+
assert(createdUser.identity!['onesignal_id'] != null);
480+
```
481+
482+
### Getting a user by `onesignal_id`
483+
```js
484+
const oneisgnalAliasLabel = "onesignal_id";
485+
const onesignalAliasId = createdUser.identity!['onesignal_id'];
486+
487+
const fetchedUser = await api.fetchUser('<app_id>', oneisgnalAliasLabel, onesignalAliasId);
488+
```
489+
490+
### Getting a user by an alias
491+
```js
492+
const fetchedUser = await api.fetchUser('<app_id>', alias_label, alias_id);
493+
```
494+
495+
### Updating a user
496+
```js
497+
const updateUserRequest: UpdateUserRequest = {
498+
properties: {
499+
language: 'fr'
500+
}
501+
};
502+
503+
const updatedUser = await api.updateUser('<app_id>', aliasLabel, aliasId, updateUserRequest);
504+
```
505+
506+
### Deleting a user
507+
```js
508+
await api.deleteUser('<app_id>', aliasLabel, aliasId);
509+
```
510+
511+
## Subscriptions
512+
### Creating a subscription for existing user
513+
```js
514+
const createSubscriptionRequestBody: CreateSubscriptionRequestBody = {
515+
subscription: {
516+
type: "AndroidPush",
517+
token: '<subscription_token>',
518+
}
519+
};
520+
521+
const response = await api.createSubscription('<app_id>', '<alias_label>', '<alias_id>', createSubscriptionRequestBody);
522+
```
523+
524+
### Updating a subscription
525+
```js
526+
const updateSubscriptionRequestBody: UpdateSubscriptionRequestBody = {
527+
subscription: {
528+
type: "iOSPush",
529+
token: '<new-subscription-token>',
530+
}
531+
};
532+
533+
await api.updateSubscription('<app_id>', '<existing_subscription_id>', updateSubscriptionRequestBody);
534+
```
535+
536+
### Deleting a subscription
537+
```js
538+
await api.deleteSubscription('<app_id>', '<subscription_id>');
539+
```
540+
541+
### Transfer subscription ownership
542+
Transfers the subscription from one user to another.
543+
```js
544+
// Setting the user for transfering the subscription to. User is identyfied by an IdentityObject.
545+
const transferSubscriptionRequestBody: TransferSubscriptionRequestBody = {
546+
identity: otherUserIdentityObject
547+
};
548+
549+
const transferResponse = await api.transferSubscription('<app_id>', '<subscription_id>', transferSubscriptionRequestBody);
550+
```
551+
552+
## Aliases
553+
### Fetching aliases for a user
554+
```js
555+
const fetchResponse = await api.fetchAliases('<app_id>', '<subscription_id>');
556+
```
557+
558+
### Fetching user identity
559+
```js
560+
const fetchResponse = await api.fetchUserIdentity('<app_id>', '<alias_label>', '<alias_id>');
561+
```
562+
### Identifying user by alias
563+
```js
564+
const userIdentityRequestBody: UserIdentityRequestBody = {
565+
identity: {
566+
['<new_alias_label>']: '<new_alias_id>'
567+
}
568+
};
569+
570+
const identifyResponse = await api.identifyUserByAlias('<app_id>',
571+
'<existing_alias_label>',
572+
'<existing_alias_id>',
573+
userIdentityRequestBody);
574+
```
575+
576+
### Identifying user by subscription id
577+
```js
578+
const userIdentityRequestBody: UserIdentityRequestBody = {
579+
identity: {
580+
['<new_alias_label>']: '<new_alias_id>'
581+
}
582+
};
583+
584+
const identifyResponse = await api.identifyUserBySubscriptionId('<app_id>', '<existing_subscription_id>', userIdentityRequestBody);
585+
```
586+
587+
### Deleting an alias
588+
```js
589+
await api.deleteAlias('<app_id>', '<alias_label>', '<alias_id>', '<alias_label_to_delete>');
590+
```
443591
## Author
444592

445593
* Website: https://onesignal.com

0 commit comments

Comments
 (0)