diff --git a/plugin/plugin.xml b/plugin/plugin.xml index 7a2af3e..6822ac0 100644 --- a/plugin/plugin.xml +++ b/plugin/plugin.xml @@ -53,7 +53,7 @@ - + @@ -71,7 +71,7 @@ - + diff --git a/plugin/src/android/QonversionPlugin.java b/plugin/src/android/QonversionPlugin.java index a44af90..de0acfa 100644 --- a/plugin/src/android/QonversionPlugin.java +++ b/plugin/src/android/QonversionPlugin.java @@ -166,8 +166,8 @@ public void restore(CallbackContext callbackContext) { } @PluginAction(thread = ExecutionThread.UI, actionName = "remoteConfig", isAutofinish = false) - public void remoteConfig(CallbackContext callbackContext) { - qonversionSandwich.remoteConfig(Utils.getResultListener(callbackContext)); + public void remoteConfig(@Nullable String contextKey, CallbackContext callbackContext) { + qonversionSandwich.remoteConfig(contextKey, Utils.getResultListener(callbackContext)); } @PluginAction(thread = ExecutionThread.UI, actionName = "attachUserToExperiment", isAutofinish = false) diff --git a/plugin/src/ios/CDVQonversionPlugin.m b/plugin/src/ios/CDVQonversionPlugin.m index 2ab37b6..023a64e 100644 --- a/plugin/src/ios/CDVQonversionPlugin.m +++ b/plugin/src/ios/CDVQonversionPlugin.m @@ -150,7 +150,8 @@ - (void)checkTrialIntroEligibilityForProductIds:(CDVInvokedUrlCommand *)command - (void)remoteConfig:(CDVInvokedUrlCommand *)command { __block __weak CDVQonversionPlugin *weakSelf = self; - [self.qonversionSandwich remoteConfig:^(NSDictionary * _Nullable result, SandwichError * _Nullable error) { + NSString *contextKey = [command argumentAtIndex:0]; + [self.qonversionSandwich remoteConfig:contextKey :^(NSDictionary * _Nullable result, SandwichError * _Nullable error) { [weakSelf returnCordovaResult:result error:error command:command]; }]; } diff --git a/plugin/src/plugin/Mapper.ts b/plugin/src/plugin/Mapper.ts index 96266ee..95f2939 100644 --- a/plugin/src/plugin/Mapper.ts +++ b/plugin/src/plugin/Mapper.ts @@ -252,6 +252,7 @@ type QRemoteConfigurationSource = { name: string; type: string; assignmentType: string; + contextKey: string | null | undefined; }; type QExperiment = { @@ -995,7 +996,13 @@ class Mapper { const sourceType = this.convertRemoteConfigurationSourceType(remoteConfig.source.type); const assignmentType = this.convertRemoteConfigurationAssignmentType(remoteConfig.source.assignmentType); - const source = new RemoteConfigurationSource(remoteConfig.source.id, remoteConfig.source.name, sourceType, assignmentType) + const source = new RemoteConfigurationSource( + remoteConfig.source.id, + remoteConfig.source.name, + sourceType, + assignmentType, + remoteConfig.source.contextKey ?? null, + ) return new RemoteConfig(remoteConfig.payload, experiment, source); } diff --git a/plugin/src/plugin/QonversionApi.ts b/plugin/src/plugin/QonversionApi.ts index 1f10825..568476e 100644 --- a/plugin/src/plugin/QonversionApi.ts +++ b/plugin/src/plugin/QonversionApi.ts @@ -131,11 +131,11 @@ export interface QonversionApi { userInfo(): Promise; /** - * Returns Qonversion remote config object + * Returns Qonversion remote config object by {@link contextKey} or default one if the key is not specified. * Use this function to get the remote config with specific payload and experiment info. * @returns the promise with the remote config. */ - remoteConfig(): Promise + remoteConfig(contextKey: string | undefined): Promise /** * This function should be used for the test purposes only. Do not forget to delete the usage of this function before the release. diff --git a/plugin/src/plugin/QonversionInternal.ts b/plugin/src/plugin/QonversionInternal.ts index 83390b9..a61c07e 100644 --- a/plugin/src/plugin/QonversionInternal.ts +++ b/plugin/src/plugin/QonversionInternal.ts @@ -196,8 +196,8 @@ export default class QonversionInternal implements QonversionApi { return mappedUserInfo; } - async remoteConfig(): Promise { - let remoteConfig = await callNative('remoteConfig'); + async remoteConfig(contextKey: string | undefined): Promise { + let remoteConfig = await callNative('remoteConfig', [contextKey]); // noinspection UnnecessaryLocalVariableJS const mappedRemoteConfig: RemoteConfig = Mapper.convertRemoteConfig( remoteConfig diff --git a/plugin/src/plugin/RemoteConfigurationSource.ts b/plugin/src/plugin/RemoteConfigurationSource.ts index aae4716..4f48c90 100644 --- a/plugin/src/plugin/RemoteConfigurationSource.ts +++ b/plugin/src/plugin/RemoteConfigurationSource.ts @@ -5,11 +5,19 @@ export class RemoteConfigurationSource { name: string; type: RemoteConfigurationSourceType; assignmentType: RemoteConfigurationAssignmentType; + contextKey: string | null; - constructor(id: string, name: string, type: RemoteConfigurationSourceType, assignmentType: RemoteConfigurationAssignmentType) { + constructor( + id: string, + name: string, + type: RemoteConfigurationSourceType, + assignmentType: RemoteConfigurationAssignmentType, + contextKey: string | null, + ) { this.id = id; this.name = name; this.type = type; this.assignmentType = assignmentType; + this.contextKey = contextKey; } }