Skip to content

Commit 4e030ce

Browse files
committed
Safe wrap forceFlushProperties method
1 parent 728ef4d commit 4e030ce

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

ApphudSDK.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'ApphudSDK'
3-
s.version = '4.0.3'
3+
s.version = '4.0.4'
44
s.summary = 'Build and Measure In-App Subscriptions on iOS.'
55
s.description = 'Apphud covers every aspect when it comes to In-App Subscriptions from integration to analytics on iOS and Android.'
66
s.homepage = 'https://github.com/apphud/ApphudSDK'

Sources/Internal/ApphudInternal+UserUpdate.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,10 +374,17 @@ extension ApphudInternal {
374374
}
375375

376376
internal func flushUserProperties(force: Bool, completion: ((Bool) -> Void)? = nil) {
377+
let completeOnMain: (Bool) -> Void = { result in
378+
guard let completion else { return }
379+
Task { @MainActor in
380+
completion(result)
381+
}
382+
}
383+
377384
Task {
378385
let values = await self.preparePropertiesParams(isAudience: force)
379386
guard let params = values.0, let properties = values.1 else {
380-
completion?(false)
387+
completeOnMain(false)
381388
return
382389
}
383390

@@ -395,7 +402,7 @@ extension ApphudInternal {
395402
apphudLog("User Properties update failed: \(error?.localizedDescription ?? "") with code: \(code)")
396403
}
397404

398-
completion?(result)
405+
completeOnMain(result)
399406
}
400407
}
401408
}

Sources/Public/Apphud.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import Foundation
1414
import UserNotifications
1515
import SwiftUI
1616

17-
internal let apphud_sdk_version = "4.0.3"
17+
internal let apphud_sdk_version = "4.0.4"
1818

1919
// MARK: - Initialization
2020

0 commit comments

Comments
 (0)