Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
When sub ID is nullified, don't make server call
* Don't update the subscription ID to the server. Locally, we may set it to null if we get 404s and later we will get a value when user create is called.
* We were sending an Update Subscription request with "subscriptionId" = null which isn't even a valid property anyway and no-ops thus far
  • Loading branch information
nan-li committed Apr 29, 2025
commit d7cb25c2390ab99e1d653e6e98afe7c65c049538
4 changes: 2 additions & 2 deletions iOS_SDK/OneSignalSDK/OneSignalOSCore/Source/OSModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ open class OSModel: NSObject, NSCoding {
}

// We can add operation name to this... , such as enum of "updated", "deleted", "added"
public func set<T>(property: String, newValue: T) {
public func set<T>(property: String, newValue: T, preventServerUpdate: Bool = false) {
let changeArgs = OSModelChangedArgs(model: self, property: property, newValue: newValue)

changeNotifier.fire { modelChangeHandler in
modelChangeHandler.onModelUpdated(args: changeArgs, hydrating: self.hydrating)
modelChangeHandler.onModelUpdated(args: changeArgs, hydrating: self.hydrating || preventServerUpdate)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,19 @@ class OSSubscriptionModel: OSModel {
}
}

// Set via server response
/**
Typically, the subscription ID is set via server response, so don't trigger a server update call when it changes.
It can also be set to null by the SDK when the user or subscription is detected as missing.
Setting the subscription ID to null will serve as a "reset" and will later hydrate a value from a user create rquest.
*/
var subscriptionId: String? {
didSet {
guard subscriptionId != oldValue else {
return
}
self.set(property: "subscriptionId", newValue: subscriptionId)

// If the ID has changed, don't trigger a server call, since it can be set to null
self.set(property: "subscriptionId", newValue: subscriptionId, preventServerUpdate: true)

guard self.type == .push else {
return
Expand Down