Skip to content
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

[Bug]: subscriptions' languages get overwritten when logging in with same user on multiple devices (160001) #1096

Open
lmeurs opened this issue Aug 18, 2023 · 4 comments

Comments

@lmeurs
Copy link

lmeurs commented Aug 18, 2023

What happened?

During out tests we logged in with the same user on different devices. When logging in for the first time on a new device, languages of all subscriptions get reset to en.

Possibly related: #1094

What browsers are you seeing the problem on?

Chrome (Chromium)

What operating system are you running?

W11, Android 13

Steps to reproduce?

1. Implement OneSignal SDK with button calling `OneSignal.User.PushSubscription.optIn()` on click
2. Add `permissionChange` event handler for `OneSignal.Notifications` which calls `OneSignal.login(123456789)` when a user grants permission
3. Log in on device A
4. Set language to eg. _fr_ using the API
5. Check the user's language in the OneSignal dashboard
6. Log in on device B
7. Check the user's language in the OneSignal dashboard

What did you expect to happen?

I expected the originally set language to remain in tact

Relevant log output

No response

@jkasten2
Copy link
Member

@lmeurs Thanks for reporting.

Language is a User level property, it will be the most recent language set for the User.

List of properties and where they are now stored with User Model:
image

Full documentation:
https://documentation.onesignal.com/docs/user-model-migration-guide

@lmeurs
Copy link
Author

lmeurs commented Aug 18, 2023

@jkasten2: thank you for your reply. It's clear that language is a user level property. As explained at #1094 (comment) we set the user language server side through API PATCH requests to https://onesignal.com/api/v1/users/by/custom_alias/123456.

In case of a new subscription, it seems like the user's language property automatically gets overwritten by the browser's default language. Is this correct? If so, is this expected behavior? The POC is for a website in 10 languages, we need control over the stored language, so we can apply custom lanuage fallback.

@jkasten2
Copy link
Member

Thanks for the details here, that makes things very clear to me now.

I am guessing you login in the user first, authenticating with your backend, then call OneSignal.login()? If so would you be able to to give the OneSignal SDK their language preference just before calling OneSignal.login()? Example something like this:

// setLanguage doesn't exist, just a suggestion for demonstration
OneSignal.User.setLanguage(languagePreference);
OneSignal.login(myID);

If not, let me know what would ideal for you.

@lmeurs
Copy link
Author

lmeurs commented Aug 20, 2023

The flow you describe is correct, not sure how setting a custom value client side (like we currently do server side) could solve this issue.

I guess the problem is that language is a property that can be set to a custom value through the API, but automatically gets overwritten when a new subscriptions is created. I understand you have to set the initial language and all you (currently) have is the browser's preferred languages. I also understand the language getting updated in certain occasions, but maybe language should be decoupled from the browser's preferred language after once it has been set to a custom value?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants