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
|
@Binding
|
||||||
var nextProfileId: Profile.ID?
|
var nextProfileId: Profile.ID?
|
||||||
|
|
||||||
var flow: ProfileContainerView.Flow?
|
var flow: ProfileFlow?
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
debugChanges()
|
debugChanges()
|
||||||
|
|
|
@ -109,7 +109,7 @@ private struct ContainerModifier: ViewModifier {
|
||||||
@ObservedObject
|
@ObservedObject
|
||||||
var profileManager: ProfileManager
|
var profileManager: ProfileManager
|
||||||
|
|
||||||
let flow: ProfileContainerView.Flow?
|
let flow: ProfileFlow?
|
||||||
|
|
||||||
@State
|
@State
|
||||||
private var search = ""
|
private var search = ""
|
||||||
|
|
|
@ -43,7 +43,7 @@ struct ProfileGridView: View, Routable, TunnelInstallationProviding {
|
||||||
|
|
||||||
let errorHandler: ErrorHandler
|
let errorHandler: ErrorHandler
|
||||||
|
|
||||||
var flow: ProfileContainerView.Flow?
|
var flow: ProfileFlow?
|
||||||
|
|
||||||
@State
|
@State
|
||||||
private var nextProfileId: Profile.ID?
|
private var nextProfileId: Profile.ID?
|
||||||
|
|
|
@ -49,7 +49,7 @@ struct ProfileListView: View, Routable, TunnelInstallationProviding {
|
||||||
|
|
||||||
let errorHandler: ErrorHandler
|
let errorHandler: ErrorHandler
|
||||||
|
|
||||||
var flow: ProfileContainerView.Flow?
|
var flow: ProfileFlow?
|
||||||
|
|
||||||
@State
|
@State
|
||||||
private var nextProfileId: Profile.ID?
|
private var nextProfileId: Profile.ID?
|
||||||
|
|
|
@ -224,6 +224,9 @@ private extension PaywallView {
|
||||||
func onComplete(_ productIdentifier: String, result: InAppPurchaseResult) {
|
func onComplete(_ productIdentifier: String, result: InAppPurchaseResult) {
|
||||||
switch result {
|
switch result {
|
||||||
case .done:
|
case .done:
|
||||||
|
Task {
|
||||||
|
await iapManager.reloadReceipt()
|
||||||
|
}
|
||||||
isPresented = false
|
isPresented = false
|
||||||
|
|
||||||
case .pending:
|
case .pending:
|
||||||
|
|
Loading…
Reference in New Issue