Skip to content

Commit

Permalink
Add getTags method
Browse files Browse the repository at this point in the history
  • Loading branch information
shepherd-l committed Nov 17, 2023
1 parent 1fbcdc8 commit 7db3f30
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ All user functions are synchronous.
| `addTags` | Adds multiple tags for the current user. | `tags: { [key: string]: string }` |
| `removeTag` | Removes a tag for the current user. | `key: string` |
| `removeTags` | Removes multiple tags for the current user. | `keys: string[]` |
| `getTags` | Gets the current user's tags. | |

### Notifications Namespace

Expand Down
6 changes: 6 additions & 0 deletions api.json
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,12 @@
}
],
"returnType": "void"
},
{
"name": "getTags",
"isAsync": false,
"args": [],
"returnType": "{ [key: string]: string }"
}
],
"namespaces": ["PushSubscription"]
Expand Down
6 changes: 6 additions & 0 deletions src/onesignal/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,4 +335,10 @@ export default class User {
propertiesModel?.set('tags', tagsCopy);
}
}

public getTags(): { [key: string]: string } {
logMethodCall('getTags');

return OneSignal.coreDirector.getPropertiesModel()?.data?.tags;
}
}
4 changes: 4 additions & 0 deletions src/onesignal/UserNamespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,8 @@ export default class UserNamespace {
public removeTags(keys: string[]): void {
this._currentUser?.removeTags(keys);
}

public getTags(): { [key: string]: string } {
return this._currentUser?.getTags() ? this._currentUser.getTags() : {};
}
}

0 comments on commit 7db3f30

Please sign in to comment.