Skip to content

Commit 42672b0

Browse files
authored
Release 8.3.0
Release 8.3.0
2 parents 3cbf17f + 456a28d commit 42672b0

File tree

15 files changed

+174
-6
lines changed

15 files changed

+174
-6
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 8.3.0
2+
* Added functions to request remote config list - either all or for a specific set of context keys.
3+
14
## 8.2.0
25
* Added an option to load Remote Configs by the specific context keys using the `remoteConfig` method.
36

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ android {
5151

5252
dependencies {
5353
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
54-
implementation "io.qonversion.sandwich:sandwich:4.2.0"
54+
implementation "io.qonversion.sandwich:sandwich:4.3.1"
5555
implementation 'com.google.code.gson:gson:2.9.0'
5656
}

android/src/main/kotlin/com/qonversion/flutter/sdk/qonversion_flutter_sdk/QonversionPlugin.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ class QonversionPlugin : MethodCallHandler, FlutterPlugin, ActivityAware {
119119
"automationsSubscribe" -> {
120120
return automationsPlugin.subscribe()
121121
}
122+
"remoteConfigList" -> {
123+
return remoteConfigList(result)
124+
}
122125
}
123126

124127
// Methods with args
@@ -128,6 +131,7 @@ class QonversionPlugin : MethodCallHandler, FlutterPlugin, ActivityAware {
128131
"purchase" -> purchase(args, result)
129132
"updatePurchase" -> updatePurchase(args, result)
130133
"remoteConfig" -> remoteConfig(args["contextKey"] as? String, result)
134+
"remoteConfigListForContextKeys" -> remoteConfigList(args, result)
131135
"setDefinedUserProperty" -> setDefinedUserProperty(args, result)
132136
"setCustomUserProperty" -> setCustomUserProperty(args, result)
133137
"addAttributionData" -> addAttributionData(args, result)
@@ -218,6 +222,18 @@ class QonversionPlugin : MethodCallHandler, FlutterPlugin, ActivityAware {
218222
qonversionSandwich.remoteConfig(contextKey, result.toJsonResultListener())
219223
}
220224

225+
private fun remoteConfigList(result: Result) {
226+
qonversionSandwich.remoteConfigList(result.toJsonResultListener())
227+
}
228+
229+
private fun remoteConfigList(args: Map<String, Any>, result: Result) {
230+
@Suppress("UNCHECKED_CAST")
231+
val contextKeys = args["contextKeys"] as? List<String> ?: return result.noNecessaryDataError()
232+
val includeEmptyContextKey = args["includeEmptyContextKey"] as? Boolean ?: return result.noNecessaryDataError()
233+
234+
qonversionSandwich.remoteConfigList(contextKeys, includeEmptyContextKey, result.toJsonResultListener())
235+
}
236+
221237
private fun products(result: Result) {
222238
qonversionSandwich.products(result.toResultListener())
223239
}

ios/Classes/SwiftQonversionPlugin.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ public class SwiftQonversionPlugin: NSObject, FlutterPlugin {
8787
case "automationsSubscribe":
8888
automationsPlugin?.subscribe()
8989
return result(nil)
90+
91+
case "remoteConfigList":
92+
return remoteConfigList(result)
9093

9194
default:
9295
break
@@ -110,6 +113,9 @@ public class SwiftQonversionPlugin: NSObject, FlutterPlugin {
110113

111114
case "remoteConfig":
112115
return remoteConfig(args["contextKey"] as? String, result)
116+
117+
case "remoteConfigListForContextKeys":
118+
return remoteConfigList(args, result)
113119

114120
case "setDefinedUserProperty":
115121
return setDefinedUserProperty(args, result)
@@ -224,6 +230,22 @@ public class SwiftQonversionPlugin: NSObject, FlutterPlugin {
224230
qonversionSandwich?.remoteConfig(contextKey, getJsonCompletion(result))
225231
}
226232

233+
private func remoteConfigList(_ result: @escaping FlutterResult) {
234+
qonversionSandwich?.remoteConfigList(getJsonCompletion(result))
235+
}
236+
237+
private func remoteConfigList(_ args: [String: Any], _ result: @escaping FlutterResult) {
238+
guard let contextKeys = args["contextKeys"] as? [String] else {
239+
return result(FlutterError.noNecessaryData)
240+
}
241+
242+
guard let includeEmptyContextKey = args["includeEmptyContextKey"] as? Bool else {
243+
return result(FlutterError.noNecessaryData)
244+
}
245+
246+
qonversionSandwich?.remoteConfigList(contextKeys, includeEmptyContextKey:includeEmptyContextKey, getJsonCompletion(result))
247+
}
248+
227249
private func userInfo(_ result: @escaping FlutterResult) {
228250
qonversionSandwich?.userInfo(getDefaultCompletion(result))
229251
}

ios/qonversion_flutter.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Pod::Spec.new do |s|
1616
s.source_files = 'Classes/**/*'
1717
s.dependency 'Flutter'
1818
s.platform = :ios, '9.0'
19-
s.dependency "QonversionSandwich", "4.2.0"
19+
s.dependency "QonversionSandwich", "4.3.1"
2020

2121
# Flutter.framework does not contain a i386 slice. Only x86_64 simulators are supported.
2222
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS[sdk=iphonesimulator*]' => 'x86_64' }

lib/qonversion_flutter.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export 'src/dto/purchase_exception.dart';
2121
export 'src/dto/subscription_period.dart';
2222
export 'src/dto/qonversion_error.dart';
2323
export 'src/dto/remote_config.dart';
24+
export 'src/dto/remote_config_list.dart';
2425
export 'src/dto/remote_configuration_source.dart';
2526
export 'src/dto/remote_configuration_source_type.dart';
2627
export 'src/dto/remote_configuration_assignment_type.dart';
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import 'package:json_annotation/json_annotation.dart';
2+
import 'remote_config.dart';
3+
4+
part 'remote_config_list.g.dart';
5+
6+
@JsonSerializable(createToJson: false)
7+
class QRemoteConfigList {
8+
@JsonKey(name: 'remoteConfigs')
9+
final List<QRemoteConfig> remoteConfigs;
10+
11+
const QRemoteConfigList(
12+
this.remoteConfigs,
13+
);
14+
15+
QRemoteConfig? remoteConfigForContextKey(String contextKey) {
16+
return _findRemoteConfig(contextKey);
17+
}
18+
19+
QRemoteConfig? remoteConfigForEmptyContextKey() {
20+
return _findRemoteConfig(null);
21+
}
22+
23+
QRemoteConfig? _findRemoteConfig(String? contextKey) {
24+
for (QRemoteConfig config in remoteConfigs) {
25+
if (config.source.contextKey == contextKey) {
26+
return config;
27+
}
28+
}
29+
return null;
30+
}
31+
32+
factory QRemoteConfigList.fromJson(Map<String, dynamic> json) =>
33+
_$QRemoteConfigListFromJson(json);
34+
}

lib/src/dto/remote_config_list.g.dart

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/internal/constants.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ class Constants {
3131
static const kGroupId = 'groupId';
3232
static const kRemoteConfigurationId = 'remoteConfigurationId';
3333
static const kContextKey = 'contextKey';
34+
static const kContextKeys = 'contextKeys';
35+
static const kIncludeEmptyContextKey = 'includeEmptyContextKey';
3436

3537
// MethodChannel methods names
3638
static const mInitialize = 'initialize';
@@ -57,6 +59,8 @@ class Constants {
5759
static const mLogout = 'logout';
5860
static const mUserInfo = 'userInfo';
5961
static const mRemoteConfig = 'remoteConfig';
62+
static const mRemoteConfigList = 'remoteConfigList';
63+
static const mRemoteConfigListForContextKeys = 'remoteConfigListForContextKeys';
6064
static const mAttachUserToExperiment = 'attachUserToExperiment';
6165
static const mDetachUserFromExperiment = 'detachUserFromExperiment';
6266
static const mAttachUserToRemoteConfiguration = 'attachUserToRemoteConfiguration';

lib/src/internal/mapper.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import '../dto/offerings.dart';
1818
import '../dto/subscription_period.dart';
1919
import '../dto/user.dart';
2020
import '../dto/remote_config.dart';
21+
import '../dto/remote_config_list.dart';
2122
import '../dto/eligibility.dart';
2223
import '../dto/user_properties.dart';
2324
import '../dto/user_property_key.dart';
@@ -70,6 +71,14 @@ class QMapper {
7071
return QRemoteConfig.fromJson(remoteConfigMap);
7172
}
7273

74+
static QRemoteConfigList? remoteConfigListFromJson(String? jsonString) {
75+
if (jsonString == null) return null;
76+
77+
final remoteConfigListMap = Map<String, dynamic>.from(jsonDecode(jsonString));
78+
79+
return QRemoteConfigList.fromJson(remoteConfigListMap);
80+
}
81+
7382
static Map<String, QEligibility> eligibilityFromJson(String? jsonString) {
7483
if (jsonString == null) return <String, QEligibility>{};
7584

0 commit comments

Comments
 (0)