From 0f8bb7d715c4bcc3bac014f7cf9dcffb24f3d9df Mon Sep 17 00:00:00 2001 From: Ilya Taratukhin Date: Tue, 21 Jan 2025 13:41:31 +0100 Subject: [PATCH] fix: fix compatibility with React Native new architecture (v0.76+) --- TestProject/ios/Podfile.lock | 2 +- .../fingerprintjs/reactnative/RNFingerprintjsProModule.kt | 2 +- ios/RNFingerprintjsPro.m | 2 +- ios/RNFingerprintjsPro.swift | 8 ++------ src/FingerprintJsProAgent.ts | 5 +++-- 5 files changed, 8 insertions(+), 11 deletions(-) diff --git a/TestProject/ios/Podfile.lock b/TestProject/ios/Podfile.lock index 8fdebcc..9452563 100644 --- a/TestProject/ios/Podfile.lock +++ b/TestProject/ios/Podfile.lock @@ -1275,7 +1275,7 @@ SPEC CHECKSUMS: ReactCommon: 45b5d4f784e869c44a6f5a8fad5b114ca8f78c53 RNFingerprintjsPro: 7437638503c6257e54b6d84406c1b6c65a50c499 SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 - Yoga: e64aa65de36c0832d04e8c7bd614396c77a80047 + Yoga: 13c8ef87792450193e117976337b8527b49e8c03 PODFILE CHECKSUM: ab81067ce8c7c4c73b9d3ab72ba8cc955f098393 diff --git a/android/src/main/java/com/fingerprintjs/reactnative/RNFingerprintjsProModule.kt b/android/src/main/java/com/fingerprintjs/reactnative/RNFingerprintjsProModule.kt index 6c13936..02861d7 100644 --- a/android/src/main/java/com/fingerprintjs/reactnative/RNFingerprintjsProModule.kt +++ b/android/src/main/java/com/fingerprintjs/reactnative/RNFingerprintjsProModule.kt @@ -36,7 +36,7 @@ class RNFingerprintjsProModule(reactContext: ReactApplicationContext) : ReactCon } @ReactMethod - fun init(apiToken: String, regionKey: String?, endpointUrl: String?, fallbackEndpointUrls: ReadableArray, extendedResponseFormat: Boolean, pluginVersion: String) { + fun configure(apiToken: String, regionKey: String?, endpointUrl: String?, fallbackEndpointUrls: ReadableArray, extendedResponseFormat: Boolean, pluginVersion: String) { val factory = FingerprintJSFactory(reactApplicationContext) val region = when(regionKey) { "eu" -> Configuration.Region.EU diff --git a/ios/RNFingerprintjsPro.m b/ios/RNFingerprintjsPro.m index 47c31a6..cf3d9b7 100644 --- a/ios/RNFingerprintjsPro.m +++ b/ios/RNFingerprintjsPro.m @@ -2,7 +2,7 @@ @interface RCT_EXTERN_MODULE(RNFingerprintjsPro, NSObject) -RCT_EXTERN_METHOD(init:(NSString *)apiToken +RCT_EXTERN_METHOD(configure:(NSString *)apiToken region:(NSString *)region endpoint:(NSString *)endpointUrl endpointFallbacks:(NSArray *)fallbackEndpointUrls diff --git a/ios/RNFingerprintjsPro.swift b/ios/RNFingerprintjsPro.swift index 36dc311..adfc2c0 100644 --- a/ios/RNFingerprintjsPro.swift +++ b/ios/RNFingerprintjsPro.swift @@ -8,15 +8,11 @@ import FingerprintPro class RNFingerprintjsPro: NSObject { private var fpjsClient: FingerprintClientProviding? - override init() { - super.init() - } - @objc static func requiresMainQueueSetup() -> Bool { false } - @objc(init:region:endpoint:endpointFallbacks:extendedResponseFormat:pluginVersion:) - public required init(_ apiToken: String, _ region: String? = "us", _ endpoint: String?, _ endpointFallbacks: [String] = [], _ extendedResponseFormat: Bool = false, _ pluginVersion: String) { + @objc(configure:region:endpoint:endpointFallbacks:extendedResponseFormat:pluginVersion:) + public func configure(_ apiToken: String, _ region: String? = "us", _ endpoint: String?, _ endpointFallbacks: [String] = [], _ extendedResponseFormat: Bool = false, _ pluginVersion: String) { let region = RNFingerprintjsPro.parseRegion(region, endpoint: endpoint, endpointFallbacks: endpointFallbacks) let integrationInfo = [("fingerprint-pro-react-native", pluginVersion)] let configuration = Configuration(apiKey: apiToken, region: region, integrationInfo: integrationInfo, extendedResponseFormat: extendedResponseFormat) diff --git a/src/FingerprintJsProAgent.ts b/src/FingerprintJsProAgent.ts index 417ee94..5e05847 100644 --- a/src/FingerprintJsProAgent.ts +++ b/src/FingerprintJsProAgent.ts @@ -26,7 +26,7 @@ export class FingerprintJsProAgent { requestOptions = {}, }: FingerprintJsProAgentParams) { try { - NativeModules.RNFingerprintjsPro.init( + NativeModules.RNFingerprintjsPro.configure( apiKey, region, endpointUrl, @@ -36,7 +36,8 @@ export class FingerprintJsProAgent { ) this.requestOptions = requestOptions } catch (e) { - console.error('RNFingerprintjsPro init error: ', e) + console.log(apiKey, region, endpointUrl, fallbackEndpointUrls, extendedResponseFormat, packageInfo.version) + console.error('RNFingerprintjsPro configure error: ', e) } }