Skip to content

Commit

Permalink
Release 5.3.0
Browse files Browse the repository at this point in the history
Release 5.3.0
  • Loading branch information
SpertsyanKM committed Apr 4, 2024
2 parents 5c1f634 + 8574898 commit 3bdb367
Show file tree
Hide file tree
Showing 14 changed files with 120 additions and 9 deletions.
2 changes: 1 addition & 1 deletion plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-qonversion",
"version": "5.2.0",
"version": "5.3.0",
"description": "Qonversion Cordova Plugin",
"cordova": {
"id": "cordova-plugin-qonversion",
Expand Down
5 changes: 3 additions & 2 deletions plugin/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<js-module src="www/Experiment.js" name="Experiment" />
<js-module src="www/ExperimentGroup.js" name="ExperimentGroup" />
<js-module src="www/RemoteConfig.js" name="RemoteConfig" />
<js-module src="www/RemoteConfigList.js" name="RemoteConfigList" />
<js-module src="www/RemoteConfigurationSource.js" name="RemoteConfigurationSource" />
<js-module src="www/QonversionError.js" name="QonversionError" />
<js-module src="www/User.js" name="User" />
Expand All @@ -53,7 +54,7 @@
<param name="android-package" value="com.qonversion.android.sdk.QonversionPlugin"/>
</feature>
</config-file>
<framework src="io.qonversion.sandwich:sandwich:4.2.0" />
<framework src="io.qonversion.sandwich:sandwich:4.3.1" />
<source-file src="src/android/QonversionPlugin.java" target-dir="src/com/qonversion/android/sdk" />
<source-file src="src/android/EntitiesConverter.java" target-dir="src/com/qonversion/android/sdk" />
<source-file src="src/android/Utils.java" target-dir="src/com/qonversion/android/sdk" />
Expand All @@ -71,7 +72,7 @@
<source url="https://github.com/CocoaPods/Specs.git"/>
</config>
<pods use-frameworks="true">
<pod name="QonversionSandwich" spec="4.2.0" />
<pod name="QonversionSandwich" spec="4.3.1" />
</pods>
</podspec>
</platform>
Expand Down
17 changes: 16 additions & 1 deletion plugin/src/android/QonversionPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,26 @@ public void restore(CallbackContext callbackContext) {
qonversionSandwich.restore(Utils.getResultListener(callbackContext));
}

@PluginAction(thread = ExecutionThread.UI, actionName = "remoteConfig", isAutofinish = false)
@PluginAction(thread = ExecutionThread.WORKER, actionName = "remoteConfig", isAutofinish = false)
public void remoteConfig(@Nullable String contextKey, CallbackContext callbackContext) {
qonversionSandwich.remoteConfig(contextKey, Utils.getResultListener(callbackContext));
}

@PluginAction(thread = ExecutionThread.WORKER, actionName = "remoteConfigList", isAutofinish = false)
public void remoteConfigList(CallbackContext callbackContext) {
qonversionSandwich.remoteConfigList(Utils.getResultListener(callbackContext));
}

@PluginAction(thread = ExecutionThread.WORKER, actionName = "remoteConfigListForContextKeys", isAutofinish = false)
public void remoteConfigListForContextKeys(JSONArray contextKeys, boolean includeEmptyContextKey, CallbackContext callbackContext) {
try {
List<String> keysList = EntitiesConverter.convertArrayToStringList(contextKeys);
qonversionSandwich.remoteConfigList(keysList, includeEmptyContextKey, Utils.getResultListener(callbackContext));
} catch (JSONException e) {
e.printStackTrace();
}
}

@PluginAction(thread = ExecutionThread.UI, actionName = "attachUserToExperiment", isAutofinish = false)
public void attachUserToExperiment(String experimentId, String groupId, CallbackContext callbackContext) {
qonversionSandwich.attachUserToExperiment(experimentId, groupId, Utils.getEmptyResultListener(callbackContext));
Expand Down
2 changes: 2 additions & 0 deletions plugin/src/ios/CDVQonversionPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)promoPurchase:(CDVInvokedUrlCommand *)command;
- (void)subscribeOnPromoPurchases:(CDVInvokedUrlCommand *)command;
- (void)remoteConfig:(CDVInvokedUrlCommand *)command;
- (void)remoteConfigList:(CDVInvokedUrlCommand *)command;
- (void)remoteConfigListForContextKeys:(CDVInvokedUrlCommand *)command;
- (void)attachUserToExperiment:(CDVInvokedUrlCommand *)command;
- (void)detachUserFromExperiment:(CDVInvokedUrlCommand *)command;
- (void)attachUserToRemoteConfiguration:(CDVInvokedUrlCommand *)command;
Expand Down
16 changes: 16 additions & 0 deletions plugin/src/ios/CDVQonversionPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,22 @@ - (void)remoteConfig:(CDVInvokedUrlCommand *)command {
}];
}

- (void)remoteConfigList:(CDVInvokedUrlCommand *)command {
__block __weak CDVQonversionPlugin *weakSelf = self;
[_qonversionSandwich remoteConfigList:^(NSDictionary<NSString *,id> * _Nullable result, SandwichError * _Nullable error) {
[weakSelf returnCordovaResult:result error:error command:command];
}];
}

- (void)remoteConfigListForContextKeys:(CDVInvokedUrlCommand *)command {
__block __weak CDVQonversionPlugin *weakSelf = self;
NSArray *contextKeys = [command argumentAtIndex:0];
BOOL includeEmptyContextKey = [[command argumentAtIndex:1] boolValue];
[_qonversionSandwich remoteConfigList:contextKeys includeEmptyContextKey:includeEmptyContextKey :^(NSDictionary<NSString *,id> * _Nullable result, SandwichError * _Nullable error) {
[weakSelf returnCordovaResult:result error:error command:command];
}];
}

- (void)attachUserToExperiment:(CDVInvokedUrlCommand *)command {
__block __weak CDVQonversionPlugin *weakSelf = self;
NSString *experimentId = [command argumentAtIndex:0];
Expand Down
10 changes: 10 additions & 0 deletions plugin/src/plugin/Mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {Experiment} from "./Experiment";
import {ExperimentGroup} from "./ExperimentGroup";
import {SubscriptionPeriod} from "./SubscriptionPeriod";
import {RemoteConfig} from "./RemoteConfig";
import {RemoteConfigList} from "./RemoteConfigList";
import {UserProperties} from './UserProperties';
import {UserProperty} from './UserProperty';
import {RemoteConfigurationSource} from "./RemoteConfigurationSource";
Expand Down Expand Up @@ -247,6 +248,10 @@ export type QRemoteConfig = {
source: QRemoteConfigurationSource;
};

export type QRemoteConfigList = {
remoteConfigs: Array<QRemoteConfig>;
}

type QRemoteConfigurationSource = {
id: string;
name: string;
Expand Down Expand Up @@ -1007,6 +1012,11 @@ class Mapper {
return new RemoteConfig(remoteConfig.payload, experiment, source);
}

static convertRemoteConfigList(remoteConfigList: QRemoteConfigList): RemoteConfigList {
const remoteConfigs = remoteConfigList.remoteConfigs.map(config => this.convertRemoteConfig(config));
return new RemoteConfigList(remoteConfigs);
}

static convertRemoteConfigurationSourceType(type: String): RemoteConfigurationSourceType {
switch (type) {
case "experiment_control_group":
Expand Down
2 changes: 2 additions & 0 deletions plugin/src/plugin/Qonversion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {QonversionConfigBuilder} from './QonversionConfigBuilder';
import {Experiment} from "./Experiment";
import {Transaction} from './Transaction';
import {RemoteConfig} from './RemoteConfig';
import {RemoteConfigList} from './RemoteConfigList';
import {RemoteConfigurationSource} from "./RemoteConfigurationSource";
import {ExperimentGroup} from './ExperimentGroup';
import {SubscriptionPeriod} from './SubscriptionPeriod';
Expand Down Expand Up @@ -101,6 +102,7 @@ export default class Qonversion {
static Entitlement = Entitlement;
static Transaction = Transaction;
static RemoteConfig = RemoteConfig;
static RemoteConfigList = RemoteConfigList;
static Experiment = Experiment;
static LaunchMode = LaunchMode;
static Environment = Environment;
Expand Down
17 changes: 17 additions & 0 deletions plugin/src/plugin/QonversionApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {User} from './User';
import {EntitlementsUpdateListener} from './EntitlementsUpdateListener';
import {PromoPurchasesListener} from './PromoPurchasesListener';
import {RemoteConfig} from "./RemoteConfig";
import {RemoteConfigList} from "./RemoteConfigList";
import {UserProperties} from './UserProperties';
import {PurchaseModel} from './PurchaseModel';
import {PurchaseUpdateModel} from './PurchaseUpdateModel';
Expand Down Expand Up @@ -137,6 +138,22 @@ export interface QonversionApi {
*/
remoteConfig(contextKey: string | undefined): Promise<RemoteConfig>

/**
* Returns Qonversion remote config objects for all existing context key (including empty one).
* Use this function to get the remote config with specific payload and experiment info.
* @returns the promise with the remote config list.
*/
remoteConfigList(): Promise<RemoteConfigList>

/**
* Returns Qonversion remote config objects by a list of {@link contextKeys}.
* Use this function to get the remote config with specific payload and experiment info.
* @param contextKeys list of context keys to load remote configs for
* @param includeEmptyContextKey set to true if you want to include remote config with empty context key to the result
* @returns the promise with the remote config list.
*/
remoteConfigListForContextKeys(contextKeys: Array<string>, includeEmptyContextKey: boolean): Promise<RemoteConfigList>

/**
* This function should be used for the test purposes only. Do not forget to delete the usage of this function before the release.
* Use this function to attach the user to the experiment.
Expand Down
22 changes: 20 additions & 2 deletions plugin/src/plugin/QonversionInternal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Mapper, {
QOfferings,
QProduct,
QRemoteConfig,
QRemoteConfigList,
QTrialIntroEligibility,
QUser,
QUserProperties
Expand All @@ -19,11 +20,12 @@ import {QonversionApi} from './QonversionApi';
import {QonversionConfig} from './QonversionConfig';
import {EntitlementsUpdateListener} from './EntitlementsUpdateListener';
import {RemoteConfig} from "./RemoteConfig";
import {RemoteConfigList} from "./RemoteConfigList";
import {UserProperties} from './UserProperties';
import {PurchaseModel} from './PurchaseModel';
import {PurchaseUpdateModel} from './PurchaseUpdateModel';

const sdkVersion = "5.2.0";
const sdkVersion = "5.3.0";

export default class QonversionInternal implements QonversionApi {

Expand Down Expand Up @@ -197,7 +199,7 @@ export default class QonversionInternal implements QonversionApi {
}

async remoteConfig(contextKey: string | undefined): Promise<RemoteConfig> {
let remoteConfig = await callNative<QRemoteConfig>('remoteConfig', [contextKey]);
const remoteConfig = await callNative<QRemoteConfig>('remoteConfig', [contextKey]);
// noinspection UnnecessaryLocalVariableJS
const mappedRemoteConfig: RemoteConfig = Mapper.convertRemoteConfig(
remoteConfig
Expand All @@ -206,6 +208,22 @@ export default class QonversionInternal implements QonversionApi {
return mappedRemoteConfig;
}

async remoteConfigList(): Promise<RemoteConfigList> {
const remoteConfigList = await callNative<QRemoteConfigList>('remoteConfigList');
// noinspection UnnecessaryLocalVariableJS
const mappedRemoteConfigList: RemoteConfigList = Mapper.convertRemoteConfigList(remoteConfigList);

return mappedRemoteConfigList;
}

async remoteConfigListForContextKeys(contextKeys: string[], includeEmptyContextKey: boolean): Promise<RemoteConfigList> {
let remoteConfigList = await callNative<QRemoteConfigList>('remoteConfigListForContextKeys', [contextKeys, includeEmptyContextKey]);
// noinspection UnnecessaryLocalVariableJS
const mappedRemoteConfigList: RemoteConfigList = Mapper.convertRemoteConfigList(remoteConfigList);

return mappedRemoteConfigList;
}

async attachUserToExperiment(experimentId: string, groupId: string): Promise<void> {
await callNative('attachUserToExperiment', [experimentId, groupId]);
return;
Expand Down
21 changes: 21 additions & 0 deletions plugin/src/plugin/RemoteConfigList.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {RemoteConfig} from './RemoteConfig';

export class RemoteConfigList {
remoteConfigs: Array<RemoteConfig>;

constructor(remoteConfigs: Array<RemoteConfig>) {
this.remoteConfigs = remoteConfigs;
}

remoteConfigForContextKey(contextKey: string): RemoteConfig | undefined {
return this.findRemoteConfigForContextKey(contextKey);
}

remoteConfigForEmptyContextKey(): RemoteConfig | undefined {
return this.findRemoteConfigForContextKey(null);
}

private findRemoteConfigForContextKey(contextKey: string | null): RemoteConfig | undefined {
return this.remoteConfigs.find(config => config.source.contextKey == contextKey);
}
}
6 changes: 4 additions & 2 deletions sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
"android",
"ios"
],
"plugins": {}
"plugins": {
"cordova-plugin-qonversion": {}
}
}
}
}
1 change: 1 addition & 0 deletions sample/www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ <h1>Qonversion Cordova Plugin</h1>
</div>
<button id="get-products" type="button" class="qon-button top-margin">Get Products</button>
<button id="get-remote-config" type="button" class="qon-button top-margin">Get Remote Config</button>
<button id="get-remote-config-list" type="button" class="qon-button top-margin">Get Remote Config List</button>
<button id="get-offerings" type="button" class="qon-button top-margin">Get Offerings</button>
<div class="row top-margin">
<input placeholder="id1, id2, ..." id="product-ids" type="text" class="qon-input" name="product-ids" />
Expand Down
6 changes: 6 additions & 0 deletions sample/www/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const app = {
document.getElementById("update-purchase").addEventListener("click", this.updatePurchase);
document.getElementById("get-products").addEventListener("click", this.getProducts);
document.getElementById("get-remote-config").addEventListener("click", this.getRemoteConfig);
document.getElementById("get-remote-config-list").addEventListener("click", this.getRemoteConfigList);
document.getElementById("get-offerings").addEventListener("click", this.getOfferings);
document.getElementById("check-trial-into").addEventListener("click", this.checkTrialIntroEligibility);
document.getElementById("check-entitlements").addEventListener("click", this.checkEntitlements);
Expand Down Expand Up @@ -113,6 +114,11 @@ const app = {
console.log('Qonversion remote config:', remoteConfig);
},

async getRemoteConfigList() {
const remoteConfigList = await Qonversion.getSharedInstance().remoteConfigList();
console.log('Qonversion remote config list:', remoteConfigList);
},

async getOfferings() {
const offerings = await Qonversion.getSharedInstance().offerings();
console.log('Qonversion offerings:', offerings);
Expand Down
2 changes: 1 addition & 1 deletion sample/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ cordova-plugin-device@^2.1.0:
integrity sha512-FU0Lw1jZpuKOgG4v80LrfMAOIMCGfAVPumn7AwaX9S1iU/X3OPZUyoKUgP09q4bxL35IeNPkqNWVKYduAXZ1sg==

"cordova-plugin-qonversion@file:../plugin":
version "5.0.0"
version "5.2.0"
resolved "file:../plugin"

cross-spawn@^7.0.1, cross-spawn@^7.0.3:
Expand Down

0 comments on commit 3bdb367

Please sign in to comment.