From dab093bc1156b59d7d159c80baa672495b8db1da Mon Sep 17 00:00:00 2001 From: Andres Aguilar Date: Wed, 24 Aug 2022 16:18:55 -0700 Subject: [PATCH 1/3] Able to purchase products --- IapExample/ios/Configuration.storekit | 48 +++++ .../ios/IapExample.xcodeproj/project.pbxproj | 4 + .../xcschemes/IapExample.xcscheme | 3 + IapExample/ios/Podfile.lock | 4 +- IapExample/src/screens/Products.tsx | 10 +- ios/IapSerializationUtils.swift | 10 +- ios/RNIapIos.m | 6 +- ios/RNIapIos.swift | 167 +++++++++--------- src/eventEmitter.ts | 3 +- src/hooks/useIAP.ts | 4 +- src/iap.ts | 125 +------------ 11 files changed, 167 insertions(+), 217 deletions(-) create mode 100644 IapExample/ios/Configuration.storekit diff --git a/IapExample/ios/Configuration.storekit b/IapExample/ios/Configuration.storekit new file mode 100644 index 000000000..e57a4bbcb --- /dev/null +++ b/IapExample/ios/Configuration.storekit @@ -0,0 +1,48 @@ +{ + "identifier" : "5BB04EE6", + "nonRenewingSubscriptions" : [ + + ], + "products" : [ + { + "displayPrice" : "0.99", + "familyShareable" : false, + "internalID" : "FF5725DC", + "localizations" : [ + { + "description" : "", + "displayName" : "", + "locale" : "en_US" + } + ], + "productID" : "com.cooni.point1000", + "referenceName" : "1000 points", + "type" : "Consumable" + }, + { + "displayPrice" : "2.99", + "familyShareable" : false, + "internalID" : "47DD16EA", + "localizations" : [ + { + "description" : "", + "displayName" : "", + "locale" : "en_US" + } + ], + "productID" : "com.cooni.point5000", + "referenceName" : "5000 points", + "type" : "NonConsumable" + } + ], + "settings" : { + + }, + "subscriptionGroups" : [ + + ], + "version" : { + "major" : 1, + "minor" : 2 + } +} diff --git a/IapExample/ios/IapExample.xcodeproj/project.pbxproj b/IapExample/ios/IapExample.xcodeproj/project.pbxproj index 86fd3f4fc..4bbae8907 100644 --- a/IapExample/ios/IapExample.xcodeproj/project.pbxproj +++ b/IapExample/ios/IapExample.xcodeproj/project.pbxproj @@ -14,6 +14,7 @@ 13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; 7699B88040F8A987B510C191 /* libPods-IapExample-IapExampleTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 19F6CBCC0A4E27FBF8BF4A61 /* libPods-IapExample-IapExampleTests.a */; }; 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; }; + 8553967928B5A2D700E7E3CE /* Configuration.storekit in Resources */ = {isa = PBXBuildFile; fileRef = 8553967828B5A2D700E7E3CE /* Configuration.storekit */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -42,6 +43,7 @@ 5B7EB9410499542E8C5724F5 /* Pods-IapExample-IapExampleTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-IapExample-IapExampleTests.debug.xcconfig"; path = "Target Support Files/Pods-IapExample-IapExampleTests/Pods-IapExample-IapExampleTests.debug.xcconfig"; sourceTree = ""; }; 5DCACB8F33CDC322A6C60F78 /* libPods-IapExample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-IapExample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = IapExample/LaunchScreen.storyboard; sourceTree = ""; }; + 8553967828B5A2D700E7E3CE /* Configuration.storekit */ = {isa = PBXFileReference; lastKnownFileType = text; path = Configuration.storekit; sourceTree = ""; }; 89C6BE57DB24E9ADA2F236DE /* Pods-IapExample-IapExampleTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-IapExample-IapExampleTests.release.xcconfig"; path = "Target Support Files/Pods-IapExample-IapExampleTests/Pods-IapExample-IapExampleTests.release.xcconfig"; sourceTree = ""; }; ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; }; /* End PBXFileReference section */ @@ -92,6 +94,7 @@ 13B07FB61A68108700A75B9A /* Info.plist */, 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */, 13B07FB71A68108700A75B9A /* main.m */, + 8553967828B5A2D700E7E3CE /* Configuration.storekit */, ); name = IapExample; sourceTree = ""; @@ -243,6 +246,7 @@ buildActionMask = 2147483647; files = ( 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */, + 8553967928B5A2D700E7E3CE /* Configuration.storekit in Resources */, 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/IapExample/ios/IapExample.xcodeproj/xcshareddata/xcschemes/IapExample.xcscheme b/IapExample/ios/IapExample.xcodeproj/xcshareddata/xcschemes/IapExample.xcscheme index 84938ba74..c7beab13b 100644 --- a/IapExample/ios/IapExample.xcodeproj/xcshareddata/xcschemes/IapExample.xcscheme +++ b/IapExample/ios/IapExample.xcodeproj/xcshareddata/xcschemes/IapExample.xcscheme @@ -60,6 +60,9 @@ ReferencedContainer = "container:IapExample.xcodeproj"> + + { {products.map((product, index) => (