expo-iap 2.3.4-rc.3 → 2.3.4-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/ExpoIapModule.swift +26 -11
- package/package.json +1 -1
package/ios/ExpoIapModule.swift
CHANGED
|
@@ -840,14 +840,18 @@ public class ExpoIapModule: Module {
|
|
|
840
840
|
subscriptionPollingTask = Task {
|
|
841
841
|
try? await Task.sleep(nanoseconds: 1_500_000_000) // 1.5 seconds
|
|
842
842
|
|
|
843
|
-
var previousStatuses: [String:
|
|
843
|
+
var previousStatuses: [String: Bool] = [:] // Track auto-renewal state with Bool
|
|
844
844
|
|
|
845
845
|
for sku in self.pollingSkus {
|
|
846
846
|
guard let product = await self.productStore?.getProduct(productID: sku),
|
|
847
847
|
let status = try? await product.subscription?.status.first else { continue }
|
|
848
848
|
|
|
849
|
-
|
|
850
|
-
|
|
849
|
+
// Track willAutoRenew as a bool value
|
|
850
|
+
var willAutoRenew = false
|
|
851
|
+
if case .verified(let info) = status.renewalInfo {
|
|
852
|
+
willAutoRenew = info.willAutoRenew
|
|
853
|
+
}
|
|
854
|
+
previousStatuses[sku] = willAutoRenew
|
|
851
855
|
}
|
|
852
856
|
|
|
853
857
|
for _ in 1...5 {
|
|
@@ -860,18 +864,29 @@ public class ExpoIapModule: Module {
|
|
|
860
864
|
for sku in self.pollingSkus {
|
|
861
865
|
guard let product = await self.productStore?.getProduct(productID: sku),
|
|
862
866
|
let status = try? await product.subscription?.status.first,
|
|
863
|
-
let
|
|
867
|
+
let result = await product.latestTransaction else { continue }
|
|
868
|
+
|
|
869
|
+
// Try to verify the transaction
|
|
870
|
+
let transaction: Transaction
|
|
871
|
+
do {
|
|
872
|
+
transaction = try self.checkVerified(result)
|
|
873
|
+
} catch {
|
|
874
|
+
continue // Skip if verification fails
|
|
875
|
+
}
|
|
864
876
|
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
877
|
+
// Track current auto-renewal state
|
|
878
|
+
var currentWillAutoRenew = false
|
|
879
|
+
if case .verified(let info) = status.renewalInfo {
|
|
880
|
+
currentWillAutoRenew = info.willAutoRenew
|
|
881
|
+
}
|
|
868
882
|
|
|
869
|
-
|
|
870
|
-
|
|
883
|
+
// Compare with previous state
|
|
884
|
+
if let previousWillAutoRenew = previousStatuses[sku],
|
|
885
|
+
previousWillAutoRenew != currentWillAutoRenew {
|
|
871
886
|
|
|
872
887
|
var purchaseMap = serializeTransaction(transaction)
|
|
873
888
|
|
|
874
|
-
if let renewalInfo = status.renewalInfo
|
|
889
|
+
if case .verified(let renewalInfo) = status.renewalInfo {
|
|
875
890
|
if let renewalInfoDict = serializeRenewalInfo(.verified(renewalInfo)) {
|
|
876
891
|
purchaseMap["renewalInfo"] = renewalInfoDict
|
|
877
892
|
}
|
|
@@ -880,7 +895,7 @@ public class ExpoIapModule: Module {
|
|
|
880
895
|
self.sendEvent(IapEvent.PurchaseUpdated, purchaseMap)
|
|
881
896
|
self.sendEvent(IapEvent.TransactionIapUpdated, ["transaction": purchaseMap])
|
|
882
897
|
|
|
883
|
-
previousStatuses[sku] =
|
|
898
|
+
previousStatuses[sku] = currentWillAutoRenew
|
|
884
899
|
}
|
|
885
900
|
}
|
|
886
901
|
}
|