diff --git a/RNPurchases.podspec b/RNPurchases.podspec index 547027d4..82f74a2d 100644 --- a/RNPurchases.podspec +++ b/RNPurchases.podspec @@ -10,7 +10,7 @@ Pod::Spec.new do |spec| spec.authors = package['author'] spec.homepage = "https://github.com/RevenueCat/react-native-purchases" spec.license = package['license'] - spec.platforms = {:ios => "11.0", :tvos => "11.0"} + spec.platform = {:ios => "13.0", :tvos => "13.0"} spec.source = { :git => "https://github.com/RevenueCat/react-native-purchases.git" } spec.source_files = "ios/**/*.{h,m,swift}" @@ -25,6 +25,6 @@ Pod::Spec.new do |spec| ] spec.dependency "React-Core" - spec.dependency "PurchasesHybridCommon", '10.3.2' + spec.dependency "PurchasesHybridCommon", '10.0.0-beta.1' spec.swift_version = '5.7' end diff --git a/__tests__/index.test.js b/__tests__/index.test.js index 9e1ea9e9..9ef9c6a1 100644 --- a/__tests__/index.test.js +++ b/__tests__/index.test.js @@ -578,42 +578,42 @@ describe("Purchases", () => { const defaultVerificationMode = "DISABLED" Purchases.configure({apiKey: "key", appUserID: "user"}); - expect(NativeModules.RNPurchases.setupPurchases).toBeCalledWith("key", "user", false, undefined, false, false, true, defaultVerificationMode); + expect(NativeModules.RNPurchases.setupPurchases).toBeCalledWith("key", "user", false, undefined, "DEFAULT", false, true, defaultVerificationMode); Purchases.configure({apiKey: "key", appUserID: "user", observerMode: true}); - expect(NativeModules.RNPurchases.setupPurchases).toBeCalledWith("key", "user", true, undefined, false, false, true, defaultVerificationMode); + expect(NativeModules.RNPurchases.setupPurchases).toBeCalledWith("key", "user", true, undefined, "DEFAULT", false, true, defaultVerificationMode); Purchases.configure({ apiKey: "key", appUserID: "user", observerMode: false, userDefaultsSuiteName: "suite name", - usesStoreKit2IfAvailable: true + storeKitVersion: Purchases.STOREKIT_VERSION.STOREKIT_1 }); - expect(NativeModules.RNPurchases.setupPurchases).toBeCalledWith("key", "user", false, "suite name", true, false, true, defaultVerificationMode); + expect(NativeModules.RNPurchases.setupPurchases).toBeCalledWith("key", "user", false, "suite name", "STOREKIT_1", false, true, defaultVerificationMode); Purchases.configure({ apiKey: "key", appUserID: "user", observerMode: true, userDefaultsSuiteName: "suite name", - usesStoreKit2IfAvailable: true, + storeKitVersion: Purchases.STOREKIT_VERSION.DEFAULT, useAmazon: true, shouldShowInAppMessagesAutomatically: true, entitlementVerificationMode: Purchases.ENTITLEMENT_VERIFICATION_MODE.INFORMATIONAL }); - expect(NativeModules.RNPurchases.setupPurchases).toBeCalledWith("key", "user", true, "suite name", true, true, true, Purchases.ENTITLEMENT_VERIFICATION_MODE.INFORMATIONAL); + expect(NativeModules.RNPurchases.setupPurchases).toBeCalledWith("key", "user", true, "suite name", "DEFAULT", true, true, Purchases.ENTITLEMENT_VERIFICATION_MODE.INFORMATIONAL); Purchases.configure({ apiKey: "key", appUserID: "user", observerMode: true, userDefaultsSuiteName: "suite name", - usesStoreKit2IfAvailable: true, + storeKitVersion: Purchases.STOREKIT_VERSION.STOREKIT_2, useAmazon: true, shouldShowInAppMessagesAutomatically: false }); - expect(NativeModules.RNPurchases.setupPurchases).toBeCalledWith("key", "user", true, "suite name", true, true, false, defaultVerificationMode); + expect(NativeModules.RNPurchases.setupPurchases).toBeCalledWith("key", "user", true, "suite name", "STOREKIT_2", true, false, defaultVerificationMode); expect(NativeModules.RNPurchases.setupPurchases).toBeCalledTimes(5); }) diff --git a/android/src/main/java/com/revenuecat/purchases/react/RNPurchasesModule.java b/android/src/main/java/com/revenuecat/purchases/react/RNPurchasesModule.java index 219c3ac0..9d32c99b 100644 --- a/android/src/main/java/com/revenuecat/purchases/react/RNPurchasesModule.java +++ b/android/src/main/java/com/revenuecat/purchases/react/RNPurchasesModule.java @@ -83,7 +83,7 @@ public void removeListeners(Integer count) { @ReactMethod public void setupPurchases(String apiKey, @Nullable String appUserID, boolean observerMode, @Nullable String userDefaultsSuiteName, - @Nullable Boolean usesStoreKit2IfAvailable, boolean useAmazon, + @Nullable String storeKitVersion, boolean useAmazon, boolean shouldShowInAppMessagesAutomatically, @Nullable String entitlementVerificationMode) { PlatformInfo platformInfo = new PlatformInfo(PLATFORM_NAME, PLUGIN_VERSION); diff --git a/apitesters/purchases.ts b/apitesters/purchases.ts index fecd13a1..15cb4827 100644 --- a/apitesters/purchases.ts +++ b/apitesters/purchases.ts @@ -1,6 +1,7 @@ import { ENTITLEMENT_VERIFICATION_MODE, IN_APP_MESSAGE_TYPE, + STOREKIT_VERSION, PurchasesOffering, } from "@revenuecat/purchases-typescript-internal"; import { @@ -135,13 +136,14 @@ async function checkPurchasing( await Purchases.showInAppMessages(); await Purchases.showInAppMessages(messageTypes); + await Purchases.handleObserverModeTransaction("product_id"); } async function checkConfigure() { const apiKey: string = ""; const appUserID: string | null = ""; const observerMode: boolean = false; - const usesStoreKit2IfAvailable: boolean = true; + const storeKitVersion: STOREKIT_VERSION = Purchases.STOREKIT_VERSION.DEFAULT; const useAmazon: boolean = true; const entitlementVerificationMode: ENTITLEMENT_VERIFICATION_MODE = Purchases.ENTITLEMENT_VERIFICATION_MODE.INFORMATIONAL; @@ -158,20 +160,22 @@ async function checkConfigure() { appUserID, observerMode, userDefaultsSuiteName, + storeKitVersion }); Purchases.configure({ apiKey, appUserID, observerMode, userDefaultsSuiteName, - usesStoreKit2IfAvailable, + storeKitVersion, + entitlementVerificationMode }); Purchases.configure({ apiKey, appUserID, observerMode, userDefaultsSuiteName, - usesStoreKit2IfAvailable, + storeKitVersion, entitlementVerificationMode, }); Purchases.configure({ @@ -179,7 +183,7 @@ async function checkConfigure() { appUserID, observerMode, userDefaultsSuiteName, - usesStoreKit2IfAvailable, + storeKitVersion, entitlementVerificationMode, useAmazon, }); @@ -188,7 +192,7 @@ async function checkConfigure() { appUserID, observerMode, userDefaultsSuiteName, - usesStoreKit2IfAvailable, + storeKitVersion, useAmazon, shouldShowInAppMessagesAutomatically, }); @@ -227,6 +231,14 @@ async function checkEntitlementVerificationModeEnum( } } +function checkStoreKitVersion(status: STOREKIT_VERSION) { + switch (status) { + case STOREKIT_VERSION.DEFAULT: + case STOREKIT_VERSION.STOREKIT_1: + case STOREKIT_VERSION.STOREKIT_2: + } +} + function checkListeners() { const customerInfoUpdateListener: CustomerInfoUpdateListener = ( customerInfo diff --git a/examples/MagicWeather/ios/Podfile b/examples/MagicWeather/ios/Podfile index e4d97a4e..cba9edab 100644 --- a/examples/MagicWeather/ios/Podfile +++ b/examples/MagicWeather/ios/Podfile @@ -1,7 +1,7 @@ require_relative '../node_modules/react-native/scripts/react_native_pods' require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' -platform :ios, '11.0' +platform :ios, '13.0' target 'MagicWeatherReactNative' do config = use_native_modules! diff --git a/examples/purchaseTesterTypescript/ios/Podfile b/examples/purchaseTesterTypescript/ios/Podfile index a7ccc401..345555e0 100644 --- a/examples/purchaseTesterTypescript/ios/Podfile +++ b/examples/purchaseTesterTypescript/ios/Podfile @@ -5,7 +5,7 @@ require Pod::Executable.execute_command('node', ['-p', {paths: [process.argv[1]]}, )', __dir__]).strip -platform :ios, min_ios_version_supported +platform :ios, "13.0" prepare_react_native_project! linkage = ENV['USE_FRAMEWORKS'] diff --git a/examples/purchaseTesterTypescript/ios/Podfile.lock b/examples/purchaseTesterTypescript/ios/Podfile.lock index f5c7aff3..c32ceaa1 100644 --- a/examples/purchaseTesterTypescript/ios/Podfile.lock +++ b/examples/purchaseTesterTypescript/ios/Podfile.lock @@ -15,12 +15,13 @@ PODS: - hermes-engine/Pre-built (= 0.73.5) - hermes-engine/Pre-built (0.73.5) - libevent (2.1.12) - - PurchasesHybridCommon (10.3.2): - - RevenueCat (= 4.39.1) - - PurchasesHybridCommonUI (10.3.2): - - PurchasesHybridCommon (= 10.3.2) - - RevenueCatUI (= 4.39.1) - - RCT-Folly (2022.05.16.00): + - OpenSSL-Universal (1.1.1100) + - PurchasesHybridCommon (10.0.0-beta.1): + - RevenueCat (= 5.0.0-beta.3) + - PurchasesHybridCommonUI (10.0.0-beta.1): + - PurchasesHybridCommon (= 10.0.0-beta.1) + - RevenueCatUI (= 5.0.0-beta.3) + - RCT-Folly (2021.07.22.00): - boost - DoubleConversion - fmt (~> 6.2.1) @@ -942,132 +943,32 @@ PODS: - React-RCTFabric (0.73.5): - glog - hermes-engine - - RCT-Folly/Fabric (= 2022.05.16.00) - - React-Core - - React-debug - - React-Fabric - - React-FabricImage - - React-graphics - - React-ImageManager - - React-jsi - - React-nativeconfig - - React-RCTImage - - React-RCTText - - React-rendererdebug - - React-runtimescheduler - - React-utils - - Yoga - - React-RCTImage (0.73.5): - - RCT-Folly (= 2022.05.16.00) - - RCTTypeSafety - - React-Codegen - - React-Core/RCTImageHeaders - - React-jsi - - React-NativeModulesApple - - React-RCTNetwork - - ReactCommon - - React-RCTLinking (0.73.5): - - React-Codegen - - React-Core/RCTLinkingHeaders (= 0.73.5) - - React-jsi (= 0.73.5) - - React-NativeModulesApple - - ReactCommon - - ReactCommon/turbomodule/core (= 0.73.5) - - React-RCTNetwork (0.73.5): - - RCT-Folly (= 2022.05.16.00) - - RCTTypeSafety - - React-Codegen - - React-Core/RCTNetworkHeaders - - React-jsi - - React-NativeModulesApple - - ReactCommon - - React-RCTSettings (0.73.5): - - RCT-Folly (= 2022.05.16.00) - - RCTTypeSafety - - React-Codegen - - React-Core/RCTSettingsHeaders - - React-jsi - - React-NativeModulesApple - - ReactCommon - - React-RCTText (0.73.5): - - React-Core/RCTTextHeaders (= 0.73.5) - - Yoga - - React-RCTVibration (0.73.5): - - RCT-Folly (= 2022.05.16.00) - - React-Codegen - - React-Core/RCTVibrationHeaders - - React-jsi - - React-NativeModulesApple - - ReactCommon - - React-rendererdebug (0.73.5): - - DoubleConversion - - fmt (~> 6.2.1) - - RCT-Folly (= 2022.05.16.00) - - React-debug - - React-rncore (0.73.5) - - React-runtimeexecutor (0.73.5): - - React-jsi (= 0.73.5) - - React-runtimescheduler (0.73.5): - - glog - - hermes-engine - - RCT-Folly (= 2022.05.16.00) - - React-callinvoker - - React-cxxreact - - React-debug - - React-jsi - - React-rendererdebug - - React-runtimeexecutor - - React-utils - - React-utils (0.73.5): - - glog - - RCT-Folly (= 2022.05.16.00) - - React-debug - - ReactCommon (0.73.5): - - React-logger (= 0.73.5) - - ReactCommon/turbomodule (= 0.73.5) - - ReactCommon/turbomodule (0.73.5): + - RCT-Folly (= 2021.07.22.00) + - React-callinvoker (= 0.71.6) + - React-Core (= 0.71.6) + - React-cxxreact (= 0.71.6) + - React-jsi (= 0.71.6) + - React-logger (= 0.71.6) + - React-perflogger (= 0.71.6) + - ReactCommon/turbomodule/core (0.71.6): - DoubleConversion - - fmt (~> 6.2.1) - glog - hermes-engine - - RCT-Folly (= 2022.05.16.00) - - React-callinvoker (= 0.73.5) - - React-cxxreact (= 0.73.5) - - React-jsi (= 0.73.5) - - React-logger (= 0.73.5) - - React-perflogger (= 0.73.5) - - ReactCommon/turbomodule/bridging (= 0.73.5) - - ReactCommon/turbomodule/core (= 0.73.5) - - ReactCommon/turbomodule/bridging (0.73.5): - - DoubleConversion - - fmt (~> 6.2.1) - - glog - - hermes-engine - - RCT-Folly (= 2022.05.16.00) - - React-callinvoker (= 0.73.5) - - React-cxxreact (= 0.73.5) - - React-jsi (= 0.73.5) - - React-logger (= 0.73.5) - - React-perflogger (= 0.73.5) - - ReactCommon/turbomodule/core (0.73.5): - - DoubleConversion - - fmt (~> 6.2.1) - - glog - - hermes-engine - - RCT-Folly (= 2022.05.16.00) - - React-callinvoker (= 0.73.5) - - React-cxxreact (= 0.73.5) - - React-jsi (= 0.73.5) - - React-logger (= 0.73.5) - - React-perflogger (= 0.73.5) - - RevenueCat (4.39.1) - - RevenueCatUI (4.39.1): - - RevenueCat (= 4.39.1) - - RNPaywalls (7.24.1): - - PurchasesHybridCommonUI (= 10.3.2) + - RCT-Folly (= 2021.07.22.00) + - React-callinvoker (= 0.71.6) + - React-Core (= 0.71.6) + - React-cxxreact (= 0.71.6) + - React-jsi (= 0.71.6) + - React-logger (= 0.71.6) + - React-perflogger (= 0.71.6) + - RevenueCat (5.0.0-beta.3) + - RevenueCatUI (5.0.0-beta.3): + - RevenueCat (= 5.0.0-beta.3) + - RNPaywalls (7.21.1): + - PurchasesHybridCommonUI (= 10.0.0-beta.1) - React-Core - - RNPurchases (7.24.1): - - PurchasesHybridCommon (= 10.3.2) + - RNPurchases (7.21.1): + - PurchasesHybridCommon (= 10.0.0-beta.1) - React-Core - RNScreens (3.29.0): - glog @@ -1259,58 +1160,45 @@ SPEC CHECKSUMS: glog: c5d68082e772fa1c511173d6b30a9de2c05a69a2 hermes-engine: 1d1835b2cc54c381909d94d1b3c8e0a2f1a94a0e libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 - PurchasesHybridCommon: 222e00edaee550b48d8e9388eca9048a053f7c33 - PurchasesHybridCommonUI: 8aba2dbe988e43cd91df09802a485c1eff4f48ed - RCT-Folly: 7169b2b1c44399c76a47b5deaaba715eeeb476c0 - RCTRequired: 2544c0f1081a5fa12e108bb8cb40e5f4581ccd87 - RCTTypeSafety: 50efabe2b115c11ed03fbf3fd79e2f163ddb5d7c - React: 84221d5e0ce297bc57c4b6af539a62d812d89f10 - React-callinvoker: 5d17577ecc7f784535ebedf3aad4bcbf8f4b5117 - React-Codegen: 857e7984fc277aadde2a7a427288b6918ece7b2b - React-Core: 8e782e7e24c7843871a0d9c3c8d7c5b3ebb73832 - React-CoreModules: 7875ee247e3e6e0e683b52cd1cdda1b71618bd55 - React-cxxreact: 788cd771c6e94d44f8d472fdfae89b67226067ea - React-debug: 55c7f2b8463bfe85567c9f4ede904085601130c9 - React-Fabric: 8cb43853496bb8032420edf62e7281c53109e682 - React-FabricImage: fbdc0ef7ed58a87c77600017c19a751932de3e47 - React-graphics: dc8307b615f14e13f1081ac23ea66697808bcd29 - React-hermes: d9acaa4ebf2118d9bd8a541af8c620c467b356b6 - React-ImageManager: 2a97ddc9b1f459121697d629cfbe69712997d76f - React-jserrorhandler: b97b16674258ccaeff5a70047a097a140e76d12d - React-jsi: 1d59d0a148c76641ac577729e0268bafa494152c - React-jsiexecutor: 262b66928ad948491d03fd328bb5b822cce94647 - React-jsinspector: 32db5e364bcae8fca8cdf8891830636275add0c5 - React-logger: 0331362115f0f5b392bd7ed14636d1a3ea612479 - React-Mapbuffer: 7c35cd53a22d0be04d3f26f7881c7fb7dd230216 - react-native-safe-area-context: b97eb6f9e3b7f437806c2ce5983f479f8eb5de4b - React-nativeconfig: 1166714a4f7ea57a0df5c2cb44fbc70f98d580f9 - React-NativeModulesApple: 726664e9829eb5eed8170241000e46ead269a05f - React-perflogger: 0dd9f1725d55f8264b81efadd373fe1d9cca7dc2 - React-RCTActionSheet: 05656d2102b0d0a2676d58bad4d80106af5367b2 - React-RCTAnimation: 6c66beae98730fb7615df28caf651e295f2401e5 - React-RCTAppDelegate: 891b80c596fffcb3f90431739495d606a9a0d610 - React-RCTBlob: 8ecee445ec5fa9ed8a8621a136183c1045165100 - React-RCTFabric: f291e06bc63fef26cdd105537bae5c6a8d3bdca8 - React-RCTImage: 585b16465146cb839da02f3179ce7cb19d332642 - React-RCTLinking: 09ba11f7df62946e7ddca1b51aa3bf47b230e008 - React-RCTNetwork: e070f8d2fca60f1e9571936ce54d165e77129e76 - React-RCTSettings: b08c7ff191f0a5421aab198ea1086c9a8d513bde - React-RCTText: f6cc5a3cf0f1a4f3d1256657dca1025e4cfe45e0 - React-RCTVibration: d9948962139f9924ef87f23ab240e045e496213b - React-rendererdebug: ee05480666415f7a76e6cf0a7a50363423f44809 - React-rncore: 010565651e9cf2e4fac9517a348446789dd55e01 - React-runtimeexecutor: 56f562a608056fb0c1711d900a992e26f375d817 - React-runtimescheduler: 814b644a5f456c7df1fba7bcd9914707152527c6 - React-utils: 987a4526a2fc0acdfaf87888adfe0bf9d0452066 - ReactCommon: 2947b0bffd82ea0e58ca7928881152d4c6dae9af - RevenueCat: 237cb14ba0ba0fa07153c801585b42b73be0fe7e - RevenueCatUI: 07f7ca5cc4879a712e2e7891a7434bd35320d42b - RNPaywalls: fb73ae4db87a9f92a48005c6e0439cf8ed35049f - RNPurchases: 726bf254205d1da6ad3bcdc19cfe1991d9de5d01 - RNScreens: 17e2f657f1b09a71ec3c821368a04acbb7ebcb46 + OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c + PurchasesHybridCommon: 5257cc1e726aab5867097f40c3c5661f294e8b06 + PurchasesHybridCommonUI: fd180a4d2862ecb5edd9db404f4a17314baac66f + RCT-Folly: 424b8c9a7a0b9ab2886ffe9c3b041ef628fd4fb1 + RCTRequired: 5c6fd63b03abb06947d348dadac51c93e3485bd8 + RCTTypeSafety: 1c66daedd66f674e39ce9f40782f0d490c78b175 + React: e11ca7cdc7aa4ddd7e6a59278b808cfe17ebbd9f + React-callinvoker: 77a82869505c96945c074b80bbdc8df919646d51 + React-Codegen: 9ee33090c38ab3da3c4dc029924d50fb649f0dfc + React-Core: 44903e47b428a491f48fd0eae54caddb2ea05ebf + React-CoreModules: 83d989defdfc82be1f7386f84a56b6509f54ac74 + React-cxxreact: 058e7e6349649eae9cfcdec5854e702b26298932 + React-hermes: ba19a405804b833c9b832c1f2061ad5038bb97f2 + React-jsi: 3fe6f589c9cafbef85ed5a4be7c6dc8edfb4ab54 + React-jsiexecutor: 7894956638ff3e00819dd3f9f6f4a84da38f2409 + React-jsinspector: d5ce2ef3eb8fd30c28389d0bc577918c70821bd6 + React-logger: 9332c3e7b4ef007a0211c0a9868253aac3e1da82 + react-native-safe-area-context: 0ee144a6170530ccc37a0fd9388e28d06f516a89 + React-perflogger: 43392072a5b867a504e2b4857606f8fc5a403d7f + React-RCTActionSheet: c7b67c125bebeda9fb19fc7b200d85cb9d6899c4 + React-RCTAnimation: c2de79906f607986633a7114bee44854e4c7e2f5 + React-RCTAppDelegate: 96bc933c3228a549718a6475c4d3f9dd4bbae98d + React-RCTBlob: cf72446957310e7da6627a4bdaadf970d3a8f232 + React-RCTImage: c6093f1bf3d67c0428d779b00390617d5bd90699 + React-RCTLinking: 5de47e37937889d22599af4b99d0552bad1b1c3c + React-RCTNetwork: e7d7077e073b08e5dd486fba3fe87ccad90a9bc4 + React-RCTSettings: 72a04921b2e8fb832da7201a60ffffff2a7c62f7 + React-RCTText: 7123c70fef5367e2121fea37e65b9ad6d3747e54 + React-RCTVibration: 73d201599a64ea14b4e0b8f91b64970979fd92e6 + React-runtimeexecutor: 8692ac548bec648fa121980ccb4304afd136d584 + ReactCommon: 0c43eaeaaee231d7d8dc24fc5a6e4cf2b75bf196 + RevenueCat: 40e259013468caf616c49cd67a78e5754f123547 + RevenueCatUI: 7b9d1cc5ca8e5eabb92be8ee39c7c2352561041d + RNPaywalls: d2369def7727f3b74c51f971625d16978bcc895d + RNPurchases: fd2314142b1ea4299d3edb89c362e735f5f4ce9a + RNScreens: 3c5b9f4a9dcde752466854b6109b79c0e205dad3 SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 Yoga: a716eea57d0d3430219c0a5a233e1e93ee931eb7 -PODFILE CHECKSUM: ef31637b966dabf84533f91f817cd6515b22cbe8 +PODFILE CHECKSUM: 0ba7730e6826403cbf5ed12eaccbfb772c95217e COCOAPODS: 1.15.2 diff --git a/examples/purchaseTesterTypescript/ios/PurchaseTester.xcodeproj/project.pbxproj b/examples/purchaseTesterTypescript/ios/PurchaseTester.xcodeproj/project.pbxproj index 343c2f6b..891ee9dd 100644 --- a/examples/purchaseTesterTypescript/ios/PurchaseTester.xcodeproj/project.pbxproj +++ b/examples/purchaseTesterTypescript/ios/PurchaseTester.xcodeproj/project.pbxproj @@ -470,7 +470,7 @@ "$(inherited)", ); INFOPLIST_FILE = PurchaseTesterTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 12.4; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -495,7 +495,7 @@ COPY_PHASE_STRIP = NO; DEVELOPMENT_TEAM = 8SXR2327BM; INFOPLIST_FILE = PurchaseTesterTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 12.4; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -616,7 +616,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.4; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = ( /usr/lib/swift, "$(inherited)", @@ -691,7 +691,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.4; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = ( /usr/lib/swift, "$(inherited)", diff --git a/ios/RNPurchases.m b/ios/RNPurchases.m index eed12efc..b7fc8bd3 100644 --- a/ios/RNPurchases.m +++ b/ios/RNPurchases.m @@ -41,7 +41,7 @@ - (dispatch_queue_t)methodQueue { appUserID:(nullable NSString *)appUserID observerMode:(BOOL)observerMode userDefaultsSuiteName:(nullable NSString *)userDefaultsSuiteName - usesStoreKit2IfAvailable:(BOOL)usesStoreKit2IfAvailable + storeKitVersion:(nullable NSString *)storeKitVersion useAmazon:(BOOL)useAmazon shouldShowInAppMessagesAutomatically:(BOOL)shouldShowInAppMessagesAutomatically entitlementVerificationMode:(nullable NSString *)entitlementVerificationMode) { @@ -51,7 +51,7 @@ - (dispatch_queue_t)methodQueue { userDefaultsSuiteName:userDefaultsSuiteName platformFlavor:self.platformFlavor platformFlavorVersion:self.platformFlavorVersion - usesStoreKit2IfAvailable:usesStoreKit2IfAvailable + storeKitVersion:storeKitVersion dangerousSettings:nil shouldShowInAppMessagesAutomatically:shouldShowInAppMessagesAutomatically verificationMode:entitlementVerificationMode]; @@ -254,6 +254,22 @@ static void logUnavailablePresentCodeRedemptionSheet() { NSLog(@"[Purchases] Warning: tried to present codeRedemptionSheet, but it's only available on iOS 14.0 or greater."); } +RCT_EXPORT_METHOD(handleObserverModeTransactionForProductID:(nonnull NSString *)productID + resolve:(RCTPromiseResolveBlock)resolve + reject:(RCTPromiseRejectBlock)reject) { + if (@available(iOS 15.0, *)) { + [RCCommonFunctionality handleObserverModeTransactionForProductID:productID + completion:[self getResponseCompletionBlockWithResolve:resolve + reject:reject]]; + } else { + NSString* description = @"Tried to handle Observer Mode transaction, but it's only available on iOS 15.0 or greater."; + NSError* error = [[NSError alloc] initWithDomain: RCPurchasesErrorCodeDomain + code: RCUnsupportedError + userInfo: @{NSLocalizedDescriptionKey : description}]; + reject([NSString stringWithFormat:@"%ld", (long) error.code], [error localizedDescription], error); + } +} + #pragma mark - Subscriber Attributes RCT_EXPORT_METHOD(setProxyURLString:(nullable NSString *)proxyURLString) { diff --git a/package.json b/package.json index b4c9e446..7eeed521 100644 --- a/package.json +++ b/package.json @@ -100,6 +100,6 @@ ] }, "dependencies": { - "@revenuecat/purchases-typescript-internal": "10.3.2" + "@revenuecat/purchases-typescript-internal": "10.0.0-beta.1" } } diff --git a/react-native-purchases-ui/RNPaywalls.podspec b/react-native-purchases-ui/RNPaywalls.podspec index 71f3eb74..d6c92ce7 100644 --- a/react-native-purchases-ui/RNPaywalls.podspec +++ b/react-native-purchases-ui/RNPaywalls.podspec @@ -10,13 +10,13 @@ Pod::Spec.new do |spec| spec.authors = package['author'] spec.homepage = "https://github.com/RevenueCat/react-native-purchases" spec.license = package['license'] - spec.platform = :ios, "11.0" + spec.platform = :ios, "13.0" spec.source = { :git => "https://github.com/RevenueCat/react-native-purchases.git" } spec.source_files = "ios/**/*.{h,m,swift}" spec.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' } spec.dependency "React-Core" - spec.dependency "PurchasesHybridCommonUI", '10.3.2' + spec.dependency "PurchasesHybridCommonUI", "10.0.0-beta.1" spec.swift_version = '5.7' end diff --git a/src/purchases.ts b/src/purchases.ts index 5ef9bd75..fa21b644 100644 --- a/src/purchases.ts +++ b/src/purchases.ts @@ -32,6 +32,8 @@ import { IN_APP_MESSAGE_TYPE, ENTITLEMENT_VERIFICATION_MODE, VERIFICATION_RESULT, + STOREKIT_VERSION, + PurchasesStoreTransaction, PurchasesOffering, } from "@revenuecat/purchases-typescript-internal"; @@ -171,6 +173,13 @@ export default class Purchases { */ public static VERIFICATION_RESULT = VERIFICATION_RESULT; + /** + * Enum of StoreKit version. + * @readonly + * @enum {string} + */ + public static STOREKIT_VERSION = STOREKIT_VERSION; + /** * @internal */ @@ -186,7 +195,7 @@ export default class Purchases { * @param {String} apiKey RevenueCat API Key. Needs to be a String * @param {String?} appUserID An optional unique id for identifying the user. Needs to be a string. * @param {boolean} [observerMode=false] An optional boolean. Set this to TRUE if you have your own IAP implementation and want to use only RevenueCat's backend. Default is FALSE. - * @param {boolean} [usesStoreKit2IfAvailable=false] DEPRECATED. An optional boolean. iOS-only. Defaults to FALSE. Setting this to TRUE will enable StoreKit2 on compatible devices. + * @param {STOREKIT_VERSION} [storeKitVersion=STOREKIT_2] iOS-only. Defaults to STOREKIT_2. StoreKit 2 is only available on iOS 15+. StoreKit 1 will be used for previous iOS versions regardless of this setting. * We recommend not using this parameter, letting RevenueCat decide for you which StoreKit implementation to use. * @param {ENTITLEMENT_VERIFICATION_MODE} [entitlementVerificationMode=ENTITLEMENT_VERIFICATION_MODE.DISABLED] Sets the entitlement verifciation mode to use. For more details, check https://rev.cat/trusted-entitlements * @param {boolean} [useAmazon=false] An optional boolean. Android-only. Set this to TRUE to enable Amazon on compatible devices. @@ -199,7 +208,7 @@ export default class Purchases { appUserID = null, observerMode = false, userDefaultsSuiteName, - usesStoreKit2IfAvailable = false, + storeKitVersion = STOREKIT_VERSION.DEFAULT, useAmazon = false, shouldShowInAppMessagesAutomatically = true, entitlementVerificationMode = ENTITLEMENT_VERIFICATION_MODE.DISABLED, @@ -223,7 +232,7 @@ export default class Purchases { appUserID, observerMode, userDefaultsSuiteName, - usesStoreKit2IfAvailable, + storeKitVersion, useAmazon, shouldShowInAppMessagesAutomatically, entitlementVerificationMode @@ -731,6 +740,27 @@ export default class Purchases { ); } + /** + * iOS only. Always returns an error on iOS < 15. + * + * Use this method only if you already have your own IAP implementation using StoreKit 2 and want to use + * RevenueCat's backend. If you are using StoreKit 1 for your implementation, you do not need this method. + * + * You only need to use this method with *new* purchases. Subscription updates are observed automatically. + * + * Important: This should only be used if you have enabled observer mode during SDK configuration. + * + * @warning You need to finish the transaction yourself after calling this method. + * + * @param {string} productID Product ID that was just purchased + * @returns {Promise} If there was a transacton found and handled for the provided product ID. + */ + public static async handleObserverModeTransaction(productID: string): Promise { + await Purchases.throwIfAndroidPlatform(); + await Purchases.throwIfNotConfigured(); + return RNPurchases.handleObserverModeTransactionForProductID(productID); + } + /** * @deprecated, use enableAdServicesAttributionTokenCollection instead. * Enable automatic collection of Apple Search Ad attribution. Disabled by default diff --git a/yarn.lock b/yarn.lock index d2ca892a..bc30610d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2530,6 +2530,13 @@ __metadata: languageName: node linkType: hard +"@revenuecat/purchases-typescript-internal@npm:10.0.0-beta.1": + version: 10.0.0-beta.1 + resolution: "@revenuecat/purchases-typescript-internal@npm:10.0.0-beta.1" + checksum: 7dfac6b183011f717ddbfa70d399c661049ada98d2fbbc1990ad003f21092ed84d7281b87c23a82b7526f6ee0cd55d4de4e9ca9e2e798393ce225a3db85aced3 + languageName: node + linkType: hard + "@revenuecat/purchases-typescript-internal@npm:10.1.0": version: 10.1.0 resolution: "@revenuecat/purchases-typescript-internal@npm:10.1.0" @@ -2537,13 +2544,6 @@ __metadata: languageName: node linkType: hard -"@revenuecat/purchases-typescript-internal@npm:10.3.2": - version: 10.3.2 - resolution: "@revenuecat/purchases-typescript-internal@npm:10.3.2" - checksum: c203081b146f6b65682cfbda5a03022cee219abbea32e2479df58cb0ec327669d94a95adc576fca3a463e1465830cc7a953eb72523de1658a56dd9c43a94258f - languageName: node - linkType: hard - "@sideway/address@npm:^4.1.5": version: 4.1.5 resolution: "@sideway/address@npm:4.1.5" @@ -6993,7 +6993,7 @@ __metadata: version: 0.0.0-use.local resolution: "react-native-purchases@workspace:." dependencies: - "@revenuecat/purchases-typescript-internal": 10.3.2 + "@revenuecat/purchases-typescript-internal": 10.0.0-beta.1 "@types/jest": ^29.5.12 "@types/react": ^18.2.44 "@types/react-dom": ~18.2.0