-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add getters and observer for onesignal ID and external ID #959
Conversation
3d74e68
to
776ce81
Compare
e7ce93f
to
32af07a
Compare
Original review comments resolved; dismissing this stale review to request re-review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 9 files reviewed, 3 unresolved discussions (waiting on @emawby, @jinliu9508, @jkasten2, @nan-li, and @shepherd-l)
MIGRATION_GUIDE.md
line 226 at r1 (raw file):
Previously, nan-li (Nan) wrote…
Let's update this usage to
await OneSignal.User.getOnesignalId()
andawait OneSignal.User.getExternalId()
?
Done.
www/UserNamespace.ts
line 182 at r1 (raw file):
Previously, nan-li (Nan) wrote…
Let's add a callout in this method description, something like this that is in the native SDKs:
Important: When using the observer to retrieve the
onesignalId
, check theexternalId
as well to confirm the values are associated with the expected user.I can see people just grabbing the
onesignalId
right away and it may not necessarily have fired for the user they were expecting.
Done.
32af07a
to
c383ccf
Compare
Everything looks good, the only callout is on the UserState object. If there's no external_id, it will fire with
You'll need to set null explicitly to the object in native so that it will become:
|
Good catch, @nan-li! I've updated! |
Everything looks great, I just pulled logic into a helper method to translate values into And did a rebase on user_model/main branch. This is my testing scenario:
OneSignal.User.getOnesignalId().then(res => {
console.log("getOnesignalId: " + res); // logs null
});
OneSignal.User.getExternalId().then(res => {
console.log("getExternalId: " + res); // logs null
});
{
"current": {
"externalId": null,
"onesignalId": "1234-abcd-1234-abcd-1234"
}
}
{
"current": {
"externalId": "my-euid",
"onesignalId": "1234-abcd-1234-abcd-1234"
}
} |
- add getters for onesignal ID/external ID - add user state observer
include new User methods: - getOnesignalId - getExternalId - addEventListener/removeEventListener
Update Migration Guide
* Extract functionality to translate `null` and empty string ("") into NULL objects, into helper methods as they are used in multiple places.
876e3e6
to
2eed867
Compare
Description
One Line Summary
Add getters for onesignal ID and external ID, and a user state observer to know when these values are changed.
Details
Motivation
From developer feedback and to support integration partners, we are exposing the onesignal ID and external ID with getters.
We also want to grant developers the ability to add observers that can be called when there is a change in user state.
Testing
Manual testing
Manually tested on:
Tested adding observer for user state and calling new methods to access externalId and onesignalId. Ensured congruency between iOS and Android responses.
Affected code checklist
Checklist
Overview
Testing
Final pass
This change is