Skip to content

Commit

Permalink
Merge pull request #274 from qonversion/release/7.2.0
Browse files Browse the repository at this point in the history
Release 7.2.0
  • Loading branch information
suriksarkisyan authored Sep 25, 2023
2 parents 4922415 + 1beab13 commit 9d4c69a
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 7.2.0
* Added attach/detach remote configuration functions

## 7.1.0
* Added remote configuration source property.
* Added rate limits for API calls.
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ android {

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "io.qonversion.sandwich:sandwich:3.1.1"
implementation "io.qonversion.sandwich:sandwich:3.2.0"
implementation 'com.google.code.gson:gson:2.9.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ class QonversionPlugin : MethodCallHandler, FlutterPlugin, ActivityAware {
"checkTrialIntroEligibility" -> checkTrialIntroEligibility(args, result)
"attachUserToExperiment" -> attachUserToExperiment(args, result)
"detachUserFromExperiment" -> detachUserFromExperiment(args, result)
"attachUserToRemoteConfiguration" -> attachUserToRemoteConfiguration(args, result)
"detachUserFromRemoteConfiguration" -> detachUserFromRemoteConfiguration(args, result)
"storeSdkInfo" -> storeSdkInfo(args, result)
"identify" -> identify(args["userId"] as? String, result)
"automationsSetNotificationsToken" -> automationsPlugin.setNotificationsToken(args["notificationsToken"] as? String, result)
Expand Down Expand Up @@ -280,20 +282,30 @@ class QonversionPlugin : MethodCallHandler, FlutterPlugin, ActivityAware {
}

private fun attachUserToExperiment(args: Map<String, Any>, result: Result) {
@Suppress("UNCHECKED_CAST")
val experimentId = args["experimentId"] as? String ?: return result.noNecessaryDataError()
val groupId = args["groupId"] as? String ?: return result.noNecessaryDataError()

qonversionSandwich.attachUserToExperiment(experimentId, groupId, result.toJsonResultListener())
}

private fun detachUserFromExperiment(args: Map<String, Any>, result: Result) {
@Suppress("UNCHECKED_CAST")
val experimentId = args["experimentId"] as? String ?: return result.noNecessaryDataError()

qonversionSandwich.detachUserFromExperiment(experimentId, result.toJsonResultListener())
}

private fun attachUserToRemoteConfiguration(args: Map<String, Any>, result: Result) {
val remoteConfigurationId = args["remoteConfigurationId"] as? String ?: return result.noNecessaryDataError()

qonversionSandwich.attachUserToRemoteConfiguration(remoteConfigurationId, result.toJsonResultListener())
}

private fun detachUserFromRemoteConfiguration(args: Map<String, Any>, result: Result) {
val remoteConfigurationId = args["remoteConfigurationId"] as? String ?: return result.noNecessaryDataError()

qonversionSandwich.detachUserFromRemoteConfiguration(remoteConfigurationId, result.toJsonResultListener())
}

private fun userInfo(result: Result) {
qonversionSandwich.userInfo(result.toResultListener())
}
Expand Down
22 changes: 22 additions & 0 deletions ios/Classes/SwiftQonversionPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ public class SwiftQonversionPlugin: NSObject, FlutterPlugin {
case "detachUserFromExperiment":
return detachUserFromExperiment(args, result)

case "attachUserToRemoteConfiguration":
return attachUserToRemoteConfiguration(args, result)

case "detachUserFromRemoteConfiguration":
return detachUserFromRemoteConfiguration(args, result)

case "automationsSetNotificationsToken":
automationsPlugin?.setNotificationsToken(args["notificationsToken"] as? String, result)
return
Expand Down Expand Up @@ -295,6 +301,22 @@ public class SwiftQonversionPlugin: NSObject, FlutterPlugin {

qonversionSandwich?.detachUserFromExperiment(with: experimentId, completion: getJsonCompletion(result))
}

private func attachUserToRemoteConfiguration(_ args: [String: Any], _ result: @escaping FlutterResult) {
guard let remoteConfigurationId = args["remoteConfigurationId"] as? String else {
return result(FlutterError.noNecessaryData)
}

qonversionSandwich?.attachUserToRemoteConfiguration(with: remoteConfigurationId, completion: getJsonCompletion(result))
}

private func detachUserFromRemoteConfiguration(_ args: [String: Any], _ result: @escaping FlutterResult) {
guard let remoteConfigurationId = args["remoteConfigurationId"] as? String else {
return result(FlutterError.noNecessaryData)
}

qonversionSandwich?.detachUserFromRemoteConfiguration(with: remoteConfigurationId, completion: getJsonCompletion(result))
}

private func storeSdkInfo(_ args: [String: Any], _ result: @escaping FlutterResult) {
guard let version = args["version"] as? String,
Expand Down
2 changes: 1 addition & 1 deletion ios/qonversion_flutter.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
s.source_files = 'Classes/**/*'
s.dependency 'Flutter'
s.platform = :ios, '9.0'
s.dependency "QonversionSandwich", "3.1.1"
s.dependency "QonversionSandwich", "3.2.0"

# Flutter.framework does not contain a i386 slice. Only x86_64 simulators are supported.
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS[sdk=iphonesimulator*]' => 'x86_64' }
Expand Down
3 changes: 3 additions & 0 deletions lib/src/internal/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Constants {
static const kConfigData = 'configData';
static const kExperimentId = 'experimentId';
static const kGroupId = 'groupId';
static const kRemoteConfigurationId = 'remoteConfigurationId';

// MethodChannel methods names
static const mInitialize = 'initialize';
Expand Down Expand Up @@ -57,6 +58,8 @@ class Constants {
static const mRemoteConfig = 'remoteConfig';
static const mAttachUserToExperiment = 'attachUserToExperiment';
static const mDetachUserFromExperiment = 'detachUserFromExperiment';
static const mAttachUserToRemoteConfiguration = 'attachUserToRemoteConfiguration';
static const mDetachUserFromRemoteConfiguration = 'detachUserFromRemoteConfiguration';
static const mCollectAppleSearchAdsAttribution = 'collectAppleSearchAdsAttribution';
static const mPresentCodeRedemptionSheet = 'presentCodeRedemptionSheet';
static const mSubscribeAutomations = 'automationsSubscribe';
Expand Down
18 changes: 17 additions & 1 deletion lib/src/internal/qonversion_internal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'package:qonversion_flutter/src/internal/utils/string.dart';
import 'constants.dart';

class QonversionInternal implements Qonversion {
static const String _sdkVersion = "7.1.0";
static const String _sdkVersion = "7.2.0";

final MethodChannel _channel = MethodChannel('qonversion_plugin');

Expand Down Expand Up @@ -240,6 +240,22 @@ class QonversionInternal implements Qonversion {
return;
}

Future<void> attachUserToRemoteConfiguration(String remoteConfigurationId) async {
final args = {
Constants.kRemoteConfigurationId: remoteConfigurationId,
};
await _channel.invokeMethod(Constants.mAttachUserToRemoteConfiguration, args);
return;
}

Future<void> detachUserFromRemoteConfiguration(String remoteConfigurationId) async {
final args = {
Constants.kRemoteConfigurationId: remoteConfigurationId,
};
await _channel.invokeMethod(Constants.mDetachUserFromRemoteConfiguration, args);
return;
}

@override
Future<void> attribution(Map<dynamic, dynamic> data, QAttributionProvider provider) {
final args = {
Expand Down
8 changes: 8 additions & 0 deletions lib/src/qonversion.dart
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,14 @@ abstract class Qonversion {
/// Use this function to detach the user from the experiment.
Future<void> detachUserFromExperiment(String experimentId);

/// 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 remote configuration.
Future<void> attachUserToRemoteConfiguration(String remoteConfigurationId);

/// 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 detach the user from the remote configuration.
Future<void> detachUserFromRemoteConfiguration(String remoteConfigurationId);

/// iOS only. Returns `null` if called on Android.
///
/// Starts a promo purchase process with App Store [productId].
Expand Down
22 changes: 22 additions & 0 deletions macos/Classes/SwiftQonversionPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ public class SwiftQonversionPlugin: NSObject, FlutterPlugin {
case "detachUserFromExperiment":
return detachUserFromExperiment(args, result)

case "attachUserToRemoteConfiguration":
return attachUserToRemoteConfiguration(args, result)

case "detachUserFromRemoteConfiguration":
return detachUserFromRemoteConfiguration(args, result)

default:
return result(FlutterMethodNotImplemented)
}
Expand Down Expand Up @@ -269,6 +275,22 @@ public class SwiftQonversionPlugin: NSObject, FlutterPlugin {

qonversionSandwich?.detachUserFromExperiment(with: experimentId, completion: getJsonCompletion(result))
}

private func attachUserToRemoteConfiguration(_ args: [String: Any], _ result: @escaping FlutterResult) {
guard let remoteConfigurationId = args["remoteConfigurationId"] as? String else {
return result(FlutterError.noNecessaryData)
}

qonversionSandwich?.attachUserToRemoteConfiguration(with: remoteConfigurationId, completion: getJsonCompletion(result))
}

private func detachUserFromRemoteConfiguration(_ args: [String: Any], _ result: @escaping FlutterResult) {
guard let remoteConfigurationId = args["remoteConfigurationId"] as? String else {
return result(FlutterError.noNecessaryData)
}

qonversionSandwich?.detachUserFromRemoteConfiguration(with: remoteConfigurationId, completion: getJsonCompletion(result))
}

private func getDefaultCompletion(_ result: @escaping FlutterResult) -> BridgeCompletion {
return { data, error in
Expand Down
2 changes: 1 addition & 1 deletion macos/qonversion_flutter.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
s.source_files = 'Classes/**/*'
s.dependency 'FlutterMacOS'
s.platform = :osx, '10.12'
s.dependency "QonversionSandwich", "3.1.1"
s.dependency "QonversionSandwich", "3.2.0"

s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
s.swift_version = '5.0'
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: qonversion_flutter
description: Flutter plugin to implement in-app subscriptions and purchases. Validate user receipts and manage cross-platform access to paid content on your app. Android & iOS.
version: 7.1.0
version: 7.2.0
homepage: 'https://qonversion.io'
repository: 'https://github.com/qonversion/flutter-sdk'

Expand Down

0 comments on commit 9d4c69a

Please sign in to comment.