Skip to content

Commit 3791566

Browse files
committed
Update migration guide with user state observer and getters
1 parent 1c2439d commit 3791566

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

MIGRATION_GUIDE.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ The User name space is accessible via `OneSignal.User` and provides access to us
209209
| **Flutter** | **Description** |
210210
| ----------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
211211
| `OneSignal.User.setLanguage("en");` | *Set the 2-character language for this user.* |
212+
| `OneSignal.User.addObserver(OnUserChangeObserver observer);` <br><br>**_See below for usage_** | *Add a User State observer which contains the nullable onesignalId and externalId. The listener will be fired when these values change.* |
213+
| `await OneSignal.User.getOnesignalId();` | *Returns the nullable OneSignal ID for the current user.* |
214+
| `await OneSignal.User.getExternalId();` | *Returns the nullable External ID for the current user.* |
212215
| `OneSignal.User.addAlias("ALIAS_LABEL", "ALIAS_ID");` | *Set an alias for the current user. If this alias label already exists on this user, it will be overwritten with the new alias id.* |
213216
| `OneSignal.User.addAliases({ALIAS_LABEL_01: "ALIAS_ID_01", ALIAS_LABEL_02: "ALIAS_ID_02"});` | *Set aliases for the current user. If any alias already exists, it will be overwritten to the new values.* |
214217
| `OneSignal.User.removeAlias("ALIAS_LABEL");` | *Remove an alias from the current user.* |
@@ -223,6 +226,20 @@ The User name space is accessible via `OneSignal.User` and provides access to us
223226
| `OneSignal.User.removeTags(["KEY_01", "KEY_02"]);` | *Remove multiple tags with the provided keys from the current user.* |
224227
| `OneSignal.User.getTags();` | *Returns the local tags for the current user.* |
225228

229+
### User State Observer
230+
231+
The `OnUserChangeObserver` will be fired when the user changes. This method's parameter is the current `UserChangedState` which includes the current state.
232+
233+
```dart
234+
OneSignal.User.addObserver((state) {
235+
var userState = state.jsonRepresentation();
236+
print('OneSignal user changed: $userState');
237+
});
238+
239+
/// Remove a user state observer that has been previously added.
240+
OneSignal.User.removeObserver(observer);
241+
```
242+
226243

227244
## Push Subscription Namespace
228245

0 commit comments

Comments
 (0)