diff --git a/packages/core/ios/Sources/DdFlagsImplementation.swift b/packages/core/ios/Sources/DdFlagsImplementation.swift index f2e4cc59f..d5f638651 100644 --- a/packages/core/ios/Sources/DdFlagsImplementation.swift +++ b/packages/core/ios/Sources/DdFlagsImplementation.swift @@ -53,8 +53,9 @@ public class DdFlagsImplementation: NSObject { return client } + // Using @escaping RCTPromiseResolveBlock type will result in an issue when compiling the Swift header file. @objc - public func setEvaluationContext(_ clientName: String, targetingKey: String, attributes: NSDictionary, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) { + public func setEvaluationContext(_ clientName: String, targetingKey: String, attributes: NSDictionary, resolve: @escaping ((Any?) -> Void), reject: @escaping ((String?, String?, NSError?) -> Void)) { let client = getClient(name: clientName) guard let clientInternal = client as? FlagsClientInternal else { reject(nil, "CLIENT_NOT_INITIALIZED", nil) @@ -90,7 +91,7 @@ public class DdFlagsImplementation: NSObject { case .networkError: errorCode = "NETWORK_ERROR" } - reject(nil, errorCode, error) + reject(nil, errorCode, error as NSError) } } } diff --git a/packages/core/src/flags/DdFlags.ts b/packages/core/src/flags/DdFlags.ts index cb4ed4dbc..43714d598 100644 --- a/packages/core/src/flags/DdFlags.ts +++ b/packages/core/src/flags/DdFlags.ts @@ -45,7 +45,9 @@ class DdFlagsWrapper implements DdFlagsType { ); } - this.clients[clientName] ??= new FlagsClient(clientName); + if (!this.clients[clientName]) { + this.clients[clientName] = new FlagsClient(clientName); + } return this.clients[clientName]; }; diff --git a/packages/react-native-openfeature/src/provider.ts b/packages/react-native-openfeature/src/provider.ts index 2950b3101..6cbae29ca 100644 --- a/packages/react-native-openfeature/src/provider.ts +++ b/packages/react-native-openfeature/src/provider.ts @@ -48,7 +48,10 @@ export class DatadogOpenFeatureProvider implements Provider { private contextChangePromise = Promise.resolve(); constructor(options: DatadogOpenFeatureProviderOptions = {}) { - options.clientName ??= 'default'; + if (!options.clientName) { + options.clientName = 'default'; + } + this.options = options; this.flagsClient = DdFlags.getClient(this.options.clientName);