Reload receipt on purchase (#892)
StoreKit ProductView performs the purchases internally without calling IAPManager.purchase(), which causes the IAPManager state to be momentarily outdated. Leverage PaywallView.onComplete() to reload the receipt and eventually trigger IAPManager.objectWillChange, so that the app is immediately unlocked on a successful purchase.
This commit is contained in:
parent
bac1d494a4
commit
35c10309a7
|
@ -48,7 +48,7 @@ struct InstalledProfileView: View, Routable {
|
|||
@Binding
|
||||
var nextProfileId: Profile.ID?
|
||||
|
||||
var flow: ProfileContainerView.Flow?
|
||||
var flow: ProfileFlow?
|
||||
|
||||
var body: some View {
|
||||
debugChanges()
|
||||
|
|
|
@ -109,7 +109,7 @@ private struct ContainerModifier: ViewModifier {
|
|||
@ObservedObject
|
||||
var profileManager: ProfileManager
|
||||
|
||||
let flow: ProfileContainerView.Flow?
|
||||
let flow: ProfileFlow?
|
||||
|
||||
@State
|
||||
private var search = ""
|
||||
|
|
|
@ -43,7 +43,7 @@ struct ProfileGridView: View, Routable, TunnelInstallationProviding {
|
|||
|
||||
let errorHandler: ErrorHandler
|
||||
|
||||
var flow: ProfileContainerView.Flow?
|
||||
var flow: ProfileFlow?
|
||||
|
||||
@State
|
||||
private var nextProfileId: Profile.ID?
|
||||
|
|
|
@ -49,7 +49,7 @@ struct ProfileListView: View, Routable, TunnelInstallationProviding {
|
|||
|
||||
let errorHandler: ErrorHandler
|
||||
|
||||
var flow: ProfileContainerView.Flow?
|
||||
var flow: ProfileFlow?
|
||||
|
||||
@State
|
||||
private var nextProfileId: Profile.ID?
|
||||
|
|
|
@ -224,6 +224,9 @@ private extension PaywallView {
|
|||
func onComplete(_ productIdentifier: String, result: InAppPurchaseResult) {
|
||||
switch result {
|
||||
case .done:
|
||||
Task {
|
||||
await iapManager.reloadReceipt()
|
||||
}
|
||||
isPresented = false
|
||||
|
||||
case .pending:
|
||||
|
|
Loading…
Reference in New Issue