You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I am in The middle of migrating library react-native-usercentrics-sdk to new architecture and I am wondering if there are util functions to help me convert cxx types to NSDictionary without manually creating converting utils.
New implementation is looking like this currently:
RCT_EXPORT_METHOD(configure:(JS::NativeUsercentrics::UsercentricsOptions &)options
resolve:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject) {
NSDictionary *convertedOptions = [self usercentricsOptionsToDict:options];
[usercentricsImpl configureWithOptions:convertedOptions];
}
- (NSDictionary *) usercentricsOptionsToDict:(JS::NativeUsercentrics::UsercentricsOptions &)params {
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
if (params.settingsId()) {
dict[@"settingsId"] = params.settingsId();
}
if (params.ruleSetId()) {
dict[@"ruleSetId"] = params.ruleSetId();
}
if (params.defaultLanguage()) {
dict[@"defaultLanguage"] = params.defaultLanguage();
}
if (params.loggerLevel()) {
dict[@"loggerLevel"] = @(params.loggerLevel().value());
}
if (params.timeoutMillis()) {
dict[@"timeoutMillis"] = @(params.timeoutMillis().value());
}
if (params.version()) {
dict[@"version"] = params.version();
}
if (params.networkMode()) {
dict[@"networkMode"] = @(params.networkMode().value());
}
if (params.consentMediation()) {
dict[@"consentMediation"] = @(params.consentMediation().value());
}
if (params.initTimeoutMillis()) {
dict[@"initTimeoutMillis"] = @(params.initTimeoutMillis().value());
}
return dict;
}
There are more types which are nested so if there are utils, they would save me a lot of time.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi, I am in The middle of migrating library react-native-usercentrics-sdk to new architecture and I am wondering if there are util functions to help me convert cxx types to NSDictionary without manually creating converting utils.
New implementation is looking like this currently:
There are more types which are nested so if there are utils, they would save me a lot of time.
Beta Was this translation helpful? Give feedback.
All reactions