Skip to content

Commit a92bcee

Browse files
committed
fix onSubscriptionChanged not firing for local-
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.
1 parent d8bcc7b commit a92bcee

File tree

1 file changed

+4
-1
lines changed
  • OneSignalSDK/onesignal/core/src/main/java/com/onesignal/user/internal/subscriptions/impl

1 file changed

+4
-1
lines changed

OneSignalSDK/onesignal/core/src/main/java/com/onesignal/user/internal/subscriptions/impl/SubscriptionManager.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,10 @@ internal class SubscriptionManager(
157157
args: ModelChangedArgs,
158158
tag: String,
159159
) {
160-
val subscription = subscriptions.collection.firstOrNull { it.id == args.model.id }
160+
val subscription =
161+
subscriptions.collection.firstOrNull {
162+
args.model == (it as Subscription).model
163+
}
161164

162165
if (subscription == null) {
163166
// this shouldn't happen, but create a new subscription if a model was updated and we

0 commit comments

Comments
 (0)