Skip to content

Commit

Permalink
fix: fix compatibility with React Native new architecture (v0.76+)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilfa committed Jan 21, 2025
1 parent ec9ab6f commit 0f8bb7d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion TestProject/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1275,7 +1275,7 @@ SPEC CHECKSUMS:
ReactCommon: 45b5d4f784e869c44a6f5a8fad5b114ca8f78c53
RNFingerprintjsPro: 7437638503c6257e54b6d84406c1b6c65a50c499
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
Yoga: e64aa65de36c0832d04e8c7bd614396c77a80047
Yoga: 13c8ef87792450193e117976337b8527b49e8c03

PODFILE CHECKSUM: ab81067ce8c7c4c73b9d3ab72ba8cc955f098393

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ios/RNFingerprintjsPro.m
Original file line number Diff line number Diff line change
Expand Up @@ -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<NSString *> *)fallbackEndpointUrls
Expand Down
8 changes: 2 additions & 6 deletions ios/RNFingerprintjsPro.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions src/FingerprintJsProAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class FingerprintJsProAgent {
requestOptions = {},
}: FingerprintJsProAgentParams) {
try {
NativeModules.RNFingerprintjsPro.init(
NativeModules.RNFingerprintjsPro.configure(
apiKey,
region,
endpointUrl,
Expand All @@ -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)
}
}

Expand Down

0 comments on commit 0f8bb7d

Please sign in to comment.