-
Notifications
You must be signed in to change notification settings - Fork 371
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
[Fix] optIn() not prompting if called before push subscription is created on backend #2037
[Fix] optIn() not prompting if called before push subscription is created on backend #2037
Conversation
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.
LGTM!
It's weird that the push subscription id was compared to the model id the whole time. I guess the subscription id is updated to its model's id at some point so we didn't see this happening all the time.
@@ -157,7 +157,10 @@ internal class SubscriptionManager( | |||
args: ModelChangedArgs, | |||
tag: String, | |||
) { | |||
val subscription = subscriptions.collection.firstOrNull { it.id == args.model.id } |
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.
I see, to use id
as a getter, it would have to compare it.model.id == args.model.id
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.
Ya, since the Susbcription.id returns ""
if it starts with local-
it was not finding it, using model
always gives us the id
value
94fe2a8
to
3b85296
Compare
3c10617
to
57e8025
Compare
This is a common case where updates (such as optedIn) should still propagate even if we haven't sent the POST /users create call yet. Motivation for this test was a bug was discovered where calling OneSignal.User.pushSubscription.optIn() was not prompting for notification permission if it was called before the create User network call finished.
This is a common case where updates (such as optedIn) should still propagate even if we haven't sent the POST /users create call yet. Motivation for this test was a bug was discovered where calling OneSignal.User.pushSubscription.optIn() was not prompting for notification permission if it was called before the create User network call finished.
57e8025
to
a92bcee
Compare
Description
One Line Summary
Fix
optIn()
not prompting if called before push subscription is created on backend .Details
Motivation
It's common for developers to call
OneSignal.User.pushSubscription.optIn()
and it should prompt even if the device is offline or has connection issues.Scope
Effects internal push subscription property change events.
Testing
Unit testing
Created a new unit test to cover this case.
Manual testing
Tested on a real Samsung S21 with Android 14 (security patch level Feb 1, 2024). Clean installed example app while the device was in airplane mode, ensuring calling
optIn()
now prompts. Also tested adding an email and sms when the device was offline and then when I turn back on network connect it successfully created all the subscriptions as expected.Affected code checklist
Checklist
Overview
Testing
Final pass
This change is