Skip to content

Commit f679286

Browse files
nan-licursoragent
andcommitted
fix: apply UpdateSubscription RYW before draining the next request
Keep RYW token updates on the executor queue ahead of single-flight drain so chained PATCHes don't let an older token overwrite a newer one. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent b9f732e commit f679286

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSSubscriptionOperationExecutor.swift

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -419,14 +419,9 @@ class OSSubscriptionOperationExecutor: OSOperationExecutor {
419419
self.dispatchQueue.async {
420420
self.updateRequestQueue.removeAll(where: { $0 == request})
421421
OneSignalUserDefaults.initShared().saveCodeableData(forKey: OS_SUBSCRIPTION_EXECUTOR_UPDATE_REQUEST_QUEUE_KEY, withValue: self.updateRequestQueue)
422-
self.executeNextPendingUpdateSubscription(for: modelId, inBackground: inBackground)
423-
if inBackground {
424-
OSBackgroundTaskManager.endBackgroundTask(backgroundTaskIdentifier)
425-
}
426-
}
427422

428-
if let onesignalId = OneSignalUserManagerImpl.sharedInstance.onesignalId {
429-
if let rywToken = response?["ryw_token"] as? String
423+
if let onesignalId = OneSignalUserManagerImpl.sharedInstance.onesignalId {
424+
if let rywToken = response?["ryw_token"] as? String
430425
{
431426
let rywDelay = response?["ryw_delay"] as? NSNumber
432427
OSConsistencyManager.shared.setRywTokenAndDelay(
@@ -438,6 +433,12 @@ class OSSubscriptionOperationExecutor: OSOperationExecutor {
438433
// handle a potential regression where ryw_token is no longer returned by API
439434
OSConsistencyManager.shared.resolveConditionsWithID(id: OSIamFetchReadyCondition.CONDITIONID)
440435
}
436+
}
437+
438+
self.executeNextPendingUpdateSubscription(for: modelId, inBackground: inBackground)
439+
if inBackground {
440+
OSBackgroundTaskManager.endBackgroundTask(backgroundTaskIdentifier)
441+
}
441442
}
442443
} onFailure: { error in
443444
OneSignalLog.onesignalLog(.LL_ERROR, message: "OSSubscriptionOperationExecutor update subscription request failed with error: \(error.debugDescription)")

0 commit comments

Comments
 (0)