Skip to content

Commit 02ecf3e

Browse files
committed
Adding swift file to ios pod target
1 parent a7597a8 commit 02ecf3e

File tree

7 files changed

+28
-15
lines changed

7 files changed

+28
-15
lines changed

ios/AppsFlyerLib.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#import <AppsFlyerLib/AppsFlyerDeepLinkResult.h>
1414
#import <AppsFlyerLib/AppsFlyerDeepLink.h>
1515
#import <AppsFlyerLib/AppsFlyerConsent.h>
16-
#import <AppsFlyerLib/AppsFlyerAdRevenueData.h>
16+
#import <AppsFlyerLib/AFAdRevenueData.h>
1717

1818
NS_ASSUME_NONNULL_BEGIN
1919

ios/PCAppsFlyer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#import <objc/message.h>
1010
#if __has_include(<PurchaseConnector/PurchaseConnector.h>)
1111
#import <PurchaseConnector/PurchaseConnector.h>
12-
12+
@class TransactionFetcher;
1313
@interface PCAppsFlyer: RCTEventEmitter <RCTBridgeModule, AppsFlyerPurchaseRevenueDelegate, AppsFlyerPurchaseRevenueDataSource>
1414
// This is the PCAppsFlyer if the AppsFlyerPurchaseConnector is set to true in the podfile
1515
@end

ios/PCAppsFlyer.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#if __has_include(<PurchaseConnector/PurchaseConnector.h>)
99
#import <PurchaseConnector/PurchaseConnector.h>
10+
#import "RNAppsFlyer-Swift.h"
1011

1112
@implementation PCAppsFlyer
1213
@synthesize bridge = _bridge;

ios/RNAppsFlyer-Bridging-Header.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#ifndef _RNAppsFlyer_Bridging_Header_h
1010
#define _RNAppsFlyer_Bridging_Header_h
1111

12-
#import <Foundation/Foundation.h>
1312
#import <PurchaseConnector/PurchaseConnector.h>
1413
#import <React/RCTBridgeModule.h>
1514
#import <React/RCTViewManager.h>

ios/RNAppsFlyer.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@
196196
CLANG_WARN_UNREACHABLE_CODE = YES;
197197
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
198198
COPY_PHASE_STRIP = NO;
199+
DEFINES_MODULE = YES;
199200
ENABLE_STRICT_OBJC_MSGSEND = YES;
200201
GCC_C_LANGUAGE_STANDARD = gnu99;
201202
GCC_DYNAMIC_NO_PIC = NO;
@@ -236,6 +237,7 @@
236237
CLANG_WARN_UNREACHABLE_CODE = YES;
237238
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
238239
COPY_PHASE_STRIP = YES;
240+
DEFINES_MODULE = YES;
239241
ENABLE_NS_ASSERTIONS = NO;
240242
ENABLE_STRICT_OBJC_MSGSEND = YES;
241243
GCC_C_LANGUAGE_STANDARD = gnu99;

ios/TransactionFetcher.swift

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,37 @@ import StoreKit
1111

1212
#if canImport(PurchaseConnector)
1313
import PurchaseConnector
14-
@objc class TransactionFetcher: NSObject {
15-
@objc static func fetchTransaction(withId transactionId: String, completion: @escaping (AFSDKTransactionSK2?) -> Void) {
16-
Task {
17-
if #available(iOS 15.0, *) {
14+
@objc(TransactionFetcher)
15+
class TransactionFetcher: NSObject, RCTBridgeModule {
16+
@objc func fetchTransaction(_ transactionId: String, callback: @escaping RCTResponseSenderBlock) {
17+
if #available(iOS 15.0, *) {
18+
Task {
1819
do {
1920
let allTransactions = try await Transaction.all
20-
if let matchingTransaction = allTransactions.first(where: { $0.id == UInt64(transactionId) }) {
21+
// Unwrap verified transactions
22+
let verifiedTransactions = allTransactions.compactMap { verificationResult -> Transaction? in
23+
switch verificationResult {
24+
case .verified(let transaction):
25+
return transaction
26+
case .unverified(_, _):
27+
return nil
28+
}
29+
}
30+
31+
if let matchingTransaction = await verifiedTransactions.first(where: { $0.id == UInt64(transactionId) }) {
2132
let afTransaction = AFSDKTransactionSK2(transaction: matchingTransaction)
22-
completion(afTransaction)
33+
callback([NSNull(), afTransaction])
2334
} else {
24-
completion(nil)
35+
callback([NSNull(), NSNull()])
2536
}
2637
} catch {
2738
print("Error fetching transactions: \(error)")
28-
completion(nil)
39+
callback([error.localizedDescription, NSNull()])
2940
}
30-
} else {
31-
print("StoreKit 2 is not available on this iOS version.")
32-
completion(nil)
3341
}
42+
} else {
43+
print("StoreKit 2 is not available on this iOS version.")
44+
callback(["StoreKit 2 is not available on this iOS version.", NSNull()])
3445
}
3546
}
3647
}

react-native-appsflyer.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Pod::Spec.new do |s|
1010
s.homepage = pkg["homepage"]
1111
s.author = pkg["author"]
1212
s.source = { :git => pkg["repository"]["url"] }
13-
s.source_files = 'ios/**/*.{h,m}'
13+
s.source_files = 'ios/**/*.{h,m,swift}'
1414
s.platform = :ios, "12.0"
1515
s.static_framework = true
1616
s.dependency 'React'

0 commit comments

Comments
 (0)