Skip to content

Commit f866e92

Browse files
authored
Merge pull request #2330 from OneSignal/fix/push_sub_observer_not_firing
fix: push subscription observers not firing
2 parents ba267bf + d120b52 commit f866e92

File tree

1 file changed

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

1 file changed

+8
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,14 @@ internal class SubscriptionManager(
190190
model: SubscriptionModel,
191191
tag: String,
192192
) {
193+
// Do not remove the push subscription: we need to keep the existing push subscription and its observers
194+
// This push subscription will immediately be replaced by the new one in the [onModelAdded] event
195+
// The [onModelRemoved] event for a push subscription model should always be followed by a [onModelAdded]
196+
// event with a new push subscription model. On 404s, no push subscription models are removed.
197+
if (model.type == SubscriptionType.PUSH) {
198+
return
199+
}
200+
193201
val subscription = subscriptions.collection.firstOrNull { it.id == model.id }
194202

195203
if (subscription != null) {

0 commit comments

Comments
 (0)