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.
@@ -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: Product.SubscriptionInfo.RenewalState] = [:]
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
- previousStatuses[sku] = status.renewalInfo.verified?.willAutoRenew == true ?
850
- .willRenew : .willNotRenew
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 transaction = await product.latestTransaction?.verified else { continue }
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
- let currentRenewalState = status.renewalInfo.verified?.willAutoRenew == true ?
866
- Product.SubscriptionInfo.RenewalState.willRenew :
867
- Product.SubscriptionInfo.RenewalState.willNotRenew
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
- if let previousState = previousStatuses[sku],
870
- previousState != currentRenewalState {
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.verified {
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] = currentRenewalState
898
+ previousStatuses[sku] = currentWillAutoRenew
884
899
  }
885
900
  }
886
901
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-iap",
3
- "version": "2.3.4-rc.3",
3
+ "version": "2.3.4-rc.4",
4
4
  "description": "In App Purchase module in Expo",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",