Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ android {

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "io.qonversion:sandwich:7.8.0"
implementation "io.qonversion:sandwich:7.9.0"
implementation 'com.google.code.gson:gson:2.9.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ class NoCodesPlugin(private val messenger: BinaryMessenger, private val context:
}
}

fun showNoCodesScreen(contextKey: String?, result: Result) {
fun showNoCodesScreen(contextKey: String?, customVariables: Map<String, String>?, result: Result) {
if (contextKey != null) {
noCodesSandwich?.showScreen(contextKey)
noCodesSandwich?.showScreen(contextKey, customVariables)
result.success(null)
} else {
result.noNecessaryDataError()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ class QonversionPlugin : MethodCallHandler, FlutterPlugin, ActivityAware {
"userProperties" -> {
return userProperties(result)
}
"forceSendProperties" -> {
return forceSendProperties(result)
}
"logout" -> {
qonversionSandwich.logout()
return result.success(null)
Expand Down Expand Up @@ -159,7 +162,7 @@ class QonversionPlugin : MethodCallHandler, FlutterPlugin, ActivityAware {
// NoCodes methods
"initializeNoCodes" -> noCodesPlugin?.initializeNoCodes(args, result)
"setScreenPresentationConfig" -> noCodesPlugin?.setScreenPresentationConfig(args["config"] as? Map<String, Any>, args["contextKey"] as? String, result)
"showNoCodesScreen" -> noCodesPlugin?.showNoCodesScreen(args["contextKey"] as? String, result)
"showNoCodesScreen" -> noCodesPlugin?.showNoCodesScreen(args["contextKey"] as? String, args["customVariables"] as? Map<String, String>, result)
"setNoCodesLocale" -> noCodesPlugin?.setLocale(args["locale"] as? String, result)
"setNoCodesTheme" -> noCodesPlugin?.setTheme(args["theme"] as? String, result)
// NoCodes Purchase Delegate methods
Expand Down Expand Up @@ -252,6 +255,12 @@ class QonversionPlugin : MethodCallHandler, FlutterPlugin, ActivityAware {
qonversionSandwich.userProperties(result.toJsonResultListener())
}

private fun forceSendProperties(result: Result) {
qonversionSandwich.forceSendProperties {
result.success(null)
}
}

private fun isFallbackFileAccessible(result: Result) {
qonversionSandwich.isFallbackFileAccessible(result.toJsonResultListener())
}
Expand Down
6 changes: 4 additions & 2 deletions ios/Classes/NoCodesPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,10 @@ public class NoCodesPlugin: NSObject {
let contextKey = args["contextKey"] as? String else {
return result(FlutterError.noNecessaryData)
}

noCodesSandwich?.showScreen(contextKey)

let customVariables = args["customVariables"] as? [String: String]

noCodesSandwich?.showScreen(contextKey, customVariables: customVariables)
result(nil)
}

Expand Down
9 changes: 9 additions & 0 deletions ios/Classes/SwiftQonversionPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ public class SwiftQonversionPlugin: NSObject, FlutterPlugin {
case "userProperties":
return userProperties(result)

case "forceSendProperties":
return forceSendProperties(result)

case "presentCodeRedemptionSheet":
return presentCodeRedemptionSheet(result)

Expand Down Expand Up @@ -312,6 +315,12 @@ public class SwiftQonversionPlugin: NSObject, FlutterPlugin {
private func userProperties(_ result: @escaping FlutterResult) {
qonversionSandwich?.userProperties(getJsonCompletion(result))
}

private func forceSendProperties(_ result: @escaping FlutterResult) {
qonversionSandwich?.forceSendProperties {
result(nil)
}
}

private func restore(_ result: @escaping FlutterResult) {
qonversionSandwich?.restore(getJsonCompletion(result))
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, '13.0'
s.dependency "QonversionSandwich", "7.8.0"
s.dependency "QonversionSandwich", "7.9.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
2 changes: 2 additions & 0 deletions lib/src/internal/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class Constants {
static const kSource = 'source';
static const kLocale = 'locale';
static const kTheme = 'theme';
static const kCustomVariables = 'customVariables';

// MethodChannel methods names
static const mInitialize = 'initialize';
Expand All @@ -54,6 +55,7 @@ class Constants {
static const mSetDefinedUserProperty = 'setDefinedUserProperty';
static const mSetCustomUserProperty = 'setCustomUserProperty';
static const mUserProperties = 'userProperties';
static const mForceSendProperties = 'forceSendProperties';
static const mSetEntitlementsCacheLifetime = 'setEntitlementsCacheLifetime';
static const mSyncPurchases = 'syncPurchases';
static const mAddAttributionData = 'addAttributionData';
Expand Down
10 changes: 7 additions & 3 deletions lib/src/internal/nocodes_internal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,16 @@ class NoCodesInternal implements NoCodes {
}

@override
Future<void> showScreen(String contextKey) async {
Future<void> showScreen(String contextKey, {Map<String, String>? customVariables}) async {
if (Platform.isMacOS) {
return;
}

await _invokeMethod(Constants.mShowNoCodesScreen, {Constants.kContextKey: contextKey});

final args = <String, dynamic>{
Constants.kContextKey: contextKey,
if (customVariables != null) Constants.kCustomVariables: customVariables,
};
await _invokeMethod(Constants.mShowNoCodesScreen, args);
}

@override
Expand Down
5 changes: 5 additions & 0 deletions lib/src/internal/qonversion_internal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,11 @@ class QonversionInternal implements Qonversion {
});
}

@override
Future<void> forceSendProperties() async {
await _invokeMethod(Constants.mForceSendProperties);
}

@override
Future<QUserProperties> userProperties() async {
final rawResult = await _invokeMethod(Constants.mUserProperties);
Expand Down
10 changes: 7 additions & 3 deletions lib/src/nocodes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,14 @@ abstract class NoCodes {
String? contextKey,
});

/// Show No-Codes screen with context key
///
/// Show No-Codes screen with context key.
///
/// Optionally pass [customVariables] — a map of custom variables that will be
/// injected into the screen's JavaScript context. Variables are scoped to the
/// provided [contextKey] and only applied to that screen.
///
/// **Platform Support:** iOS and Android. No-op on macOS.
Future<void> showScreen(String contextKey);
Future<void> showScreen(String contextKey, {Map<String, String>? customVariables});

/// Close No-Codes screen
///
Expand Down
5 changes: 5 additions & 0 deletions lib/src/qonversion.dart
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@ abstract class Qonversion {
/// in the result.
Future<QUserProperties> userProperties();

/// Force-flushes any pending user property updates to the server immediately.
/// Use this when you need to ensure all previously set properties have been sent
/// before performing an operation that depends on them.
Future<void> forceSendProperties();

/// iOS only. Does nothing, if called on Android.
///
/// On iOS 14.5+, after requesting the app tracking entitlement using ATT, you need to notify Qonversion if tracking is allowed and IDFA is available.
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", "7.8.0"
s.dependency "QonversionSandwich", "7.9.0"

s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
s.swift_version = '5.0'
Expand Down
Loading