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

[question]: when i register a user in my backend, how do i retain OneSignal user and ID in a Flutter app? #966

Open
1 task done
jaanusStagnation opened this issue Oct 24, 2024 · 1 comment

Comments

@jaanusStagnation
Copy link

How can we help?

We have a Flutter app

We use OneSignal with RevenueCat in our system. When we initialize the app both SDKs create anonymous accounts for the user. When a user is logged in, it switches the context to the specific externalID we provide. What we assumed would happen is that the OneSignal ID from the Flutter SDK to RevenuCat, would upon registering a new user in our database and using the login(externalID) method on both SDKs, they would retain the anonymous users and upgrade them to actual accounts.
However what i have tested - RevenueCat retains the user and adds the external ID to the existing account. OneSignal instead decides to delete the User and subscription from its system and creates a new one (the OneSignal ID generated on initialization is removed entirely). This means that all data collected before login(...) is erased and RevenueCat needs to be updated along with the new ID and i would need to copy tags before login and paste after login to retain at least some data.

Is it possible to retain the OneSignal anonymous user the SDK generates if logged out of OneSignal and somehow append the externalID to the existing OneSignal user?

Code of Conduct

  • I agree to follow this project's Code of Conduct
@jaanusStagnation
Copy link
Author

jaanusStagnation commented Oct 28, 2024

i noticed the SDK reference document shows that it should keep the anonymous user ID if the external ID does not exist. However this is not true, atleast for the flutter SDK
image
we register the oneSignalID to RC at the start up of the app (this is confirmed to pass the ID since it generates this on initialization)
final oneSignalId = await OneSignal.User.getOnesignalId();
await Purchases.setAttributes({'\$onesignalUserId': oneSignalId});

however after the below step, the temporary user is erased from OneSignal user list and a new one is generated in its place
await OneSignal.login(user.id);
await OneSignal.User.addEmail(user.email);
await OneSignal.User.addTagWithKey('full_name', user.name);

the external ID provided does not exist on the OneSignal account so why is the temporary user deleted?

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

1 participant