@@ -14,6 +14,7 @@ @implementation PCAppsFlyer
1414static NSString *const logSubscriptionsKey = @" logSubscriptions" ;
1515static NSString *const logInAppsKey = @" logInApps" ;
1616static NSString *const sandboxKey = @" sandbox" ;
17+ static NSString *const storeKitKey = @" storeKitVersion" ;
1718static NSString *const connectorAlreadyConfiguredMessage = @" Connector already configured" ;
1819static NSString *const connectorNotConfiguredMessage = @" Connector not configured, did you call `create` first?" ;
1920
@@ -41,8 +42,18 @@ @implementation PCAppsFlyer
4142 BOOL logSubscriptions = [config[logSubscriptionsKey] boolValue ];
4243 BOOL logInApps = [config[logInAppsKey] boolValue ];
4344 BOOL sandbox = [config[sandboxKey] boolValue ];
44-
45+ NSString *storeKitVersion = config[storeKitKey];
46+
4547 [connector setIsSandbox: sandbox];
48+
49+ // Set the StoreKitVersion (default to SK1 if not provided or invalid)
50+ if ([storeKitVersion isEqualToString: @" SK2" ]) {
51+ [connector setStoreKitVersion: AFSDKStoreKitVersionSK2];
52+ NSLog (@" %@ Configure PurchaseConnector with StoreKit2 Version" , TAG);
53+ } else {
54+ [connector setStoreKitVersion: AFSDKStoreKitVersionSK1];
55+ NSLog (@" %@ Configure PurchaseConnector with StoreKit1 Version" , TAG);
56+ }
4657
4758 if (logSubscriptions && logInApps) {
4859 [connector setAutoLogPurchaseRevenue: AFSDKAutoLogPurchaseRevenueOptionsAutoRenewableSubscriptions | AFSDKAutoLogPurchaseRevenueOptionsInAppPurchases];
@@ -58,6 +69,35 @@ @implementation PCAppsFlyer
5869 resolve (nil );
5970}
6071
72+ RCT_EXPORT_METHOD (logConsumableTransaction:(NSString *)transactionId
73+ resolver:(RCTPromiseResolveBlock)resolve
74+ rejecter:(RCTPromiseRejectBlock)reject) {
75+ NSLog (@" %@ Logging consumable transaction with ID: %@ " , TAG, transactionId);
76+
77+ if (connector == nil ) {
78+ reject (connectorNotConfiguredMessage, connectorNotConfiguredMessage, nil );
79+ return ;
80+ }
81+
82+ // Call the Swift method via the TransactionFetcher class
83+ /*
84+ [TransactionFetcher fetchTransactionWithId:transactionId completion:^(AFSDKTransactionSK2 * _Nullable afTransaction) {
85+ if (afTransaction) {
86+ // Use the fetched transaction
87+ [connector logConsumableTransaction:afTransaction];
88+ NSLog(@"Logged transaction: %@", transactionId);
89+ resolve(nil);
90+ } else {
91+ // Handle the case where the transaction was not found
92+ NSError *error = [NSError errorWithDomain:@"PCAppsFlyer"
93+ code:404
94+ userInfo:@{NSLocalizedDescriptionKey: @"Transaction not found"}];
95+ reject(@"transaction_not_found", @"Transaction not found", error);
96+ }
97+ }];
98+ */
99+ }
100+
61101RCT_EXPORT_METHOD (startObservingTransactions:(RCTPromiseResolveBlock)resolve
62102 rejecter:(RCTPromiseRejectBlock)reject) {
63103 NSLog (@" %@ Starting to observe transactions." , TAG);
0 commit comments