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
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,17 @@ class NoCodesPlugin(private val messenger: BinaryMessenger, private val context:
this.screenFailedToLoadEventStreamHandler = screenFailedToLoadListener.eventStreamHandler
}

fun initializeNoCodes(projectKey: String, result: Result) {
fun initializeNoCodes(args: Map<String, Any>, result: Result) {
val projectKey = args["projectKey"] as? String ?: return result.noNecessaryDataError()
val version = args["version"] as? String ?: return result.noNecessaryDataError()
val source = args["source"] as? String ?: return result.noNecessaryDataError()

if (projectKey.isNotEmpty()) {
// Initialize NoCodes Sandwich
noCodesSandwich = NoCodesSandwich()

noCodesSandwich?.storeSdkInfo(context, source, version)

noCodesSandwich?.initialize(context, projectKey)
noCodesSandwich?.setDelegate(this)
result.success(null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class QonversionPlugin : MethodCallHandler, FlutterPlugin, ActivityAware {
"storeSdkInfo" -> storeSdkInfo(args, result)
"identify" -> identify(args["userId"] as? String, result)
// NoCodes methods
"initializeNoCodes" -> noCodesPlugin?.initializeNoCodes(args["projectKey"] as? String ?: "", result)
"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)
else -> result.notImplemented()
Expand Down
1 change: 1 addition & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ ios/Podfile.lock

# Android related
android/keystore/
.cxx/

# Web related
lib/generated_plugin_registrant.dart
Expand Down
9 changes: 5 additions & 4 deletions lib/qonversion_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ export 'src/dto/entitlement_source.dart';
export 'src/dto/entitlements_cache_lifetime.dart';
export 'src/dto/environment.dart';
export 'src/dto/launch_mode.dart';
export 'src/dto/nocodes_events.dart';
export 'src/dto/offerings.dart';
export 'src/dto/presentation_config.dart';
export 'src/dto/product.dart';
export 'src/dto/product_type.dart';
export 'src/dto/promotional_offer.dart';
Expand Down Expand Up @@ -42,10 +44,9 @@ export 'src/dto/store_product/product_offer_details.dart';
export 'src/dto/store_product/product_price.dart';
export 'src/dto/store_product/product_pricing_phase.dart';
export 'src/dto/store_product/product_store_details.dart';
export 'src/nocodes.dart';
export 'src/nocodes_config.dart';
export 'src/nocodes_config_builder.dart';
export 'src/qonversion.dart';
export 'src/qonversion_config.dart';
export 'src/qonversion_config_builder.dart';
export 'src/nocodes/nocodes.dart';
export 'src/nocodes/nocodes_config.dart';
export 'src/nocodes/nocodes_events.dart';
export 'src/nocodes/presentation_config.dart';
File renamed without changes.
5 changes: 4 additions & 1 deletion lib/src/internal/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class Constants {
static const kDiscountId = 'discountId';
static const kPromoOffer = 'promoOffer';
static const kConfig = 'config';
static const kVersion = 'version';
static const kSource = 'source';

// MethodChannel methods names
static const mInitialize = 'initialize';
Expand Down Expand Up @@ -74,6 +76,7 @@ class Constants {
static const mShowNoCodesScreen = 'showNoCodesScreen';
static const mCloseNoCodes = 'closeNoCodes';

// Numeric constants
// Other constants
static const skuDetailsPriceRatio = 1000000;
static const sdkSource = "flutter";
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import 'dart:async';
import 'dart:io';
import 'package:flutter/services.dart';
import 'nocodes_events.dart';
import 'nocodes_config.dart';
import 'nocodes.dart';
import 'presentation_config.dart';
import 'package:qonversion_flutter/src/internal/qonversion_internal.dart';
import '../dto/nocodes_events.dart';
import '../dto/presentation_config.dart';
import '../nocodes_config.dart';
import '../nocodes.dart';
import 'dart:convert';
import '../internal/constants.dart';

Expand All @@ -28,9 +29,11 @@ class NoCodesInternal implements NoCodes {
if (Platform.isMacOS) {
return;
}

final args = {
Constants.kProjectKey: config.projectKey,
Constants.kVersion: QonversionInternal.sdkVersion,
Constants.kSource: Constants.sdkSource,
};
_channel.invokeMethod(Constants.mInitializeNoCodes, args);
}
Expand Down Expand Up @@ -152,4 +155,4 @@ class NoCodesInternal implements NoCodes {

await _channel.invokeMethod(Constants.mCloseNoCodes);
}
}
}
6 changes: 3 additions & 3 deletions 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 = "10.0.2";
static const String sdkVersion = "10.0.2";

final MethodChannel _channel = MethodChannel('qonversion_plugin');

Expand Down Expand Up @@ -402,8 +402,8 @@ class QonversionInternal implements Qonversion {
// Private methods
Future<void> _storeSdkInfo() =>
_channel.invokeMethod(Constants.mStoreSdkInfo, {
"version": _sdkVersion,
"source": "flutter",
Constants.kVersion: sdkVersion,
Constants.kSource: Constants.sdkSource,
});

static QPurchaseException _convertPurchaseException(PlatformException error) {
Expand Down
6 changes: 3 additions & 3 deletions lib/src/nocodes/nocodes.dart → lib/src/nocodes.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'dart:async';
import 'nocodes_events.dart';
import 'dto/nocodes_events.dart';
import 'dto/presentation_config.dart';
import 'nocodes_config.dart';
import 'nocodes_internal.dart';
import 'presentation_config.dart';
import 'internal/nocodes_internal.dart';

/// Main No-Codes API class
///
Expand Down
6 changes: 6 additions & 0 deletions lib/src/nocodes_config.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/// Configuration for No-Codes initialization
class NoCodesConfig {
final String projectKey;

const NoCodesConfig(this.projectKey);
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
/// Configuration for NoCodes initialization
class NoCodesConfig {
final String projectKey;

const NoCodesConfig(this.projectKey);
}
import 'nocodes_config.dart';

/// Builder for NoCodes configuration
/// Builder for No-Codes configuration
class NoCodesConfigBuilder {
final String projectKey;

Expand All @@ -17,4 +12,4 @@ class NoCodesConfigBuilder {
NoCodesConfig build() {
return NoCodesConfig(projectKey);
}
}
}
16 changes: 8 additions & 8 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ packages:
dependency: transitive
description:
name: async
sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb"
sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63
url: "https://pub.dev"
source: hosted
version: "2.13.0"
version: "2.12.0"
boolean_selector:
dependency: transitive
description:
Expand Down Expand Up @@ -173,10 +173,10 @@ packages:
dependency: transitive
description:
name: fake_async
sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44"
sha256: "6a95e56b2449df2273fd8c45a662d6947ce1ebb7aafe80e550a3f68297f3cacc"
url: "https://pub.dev"
source: hosted
version: "1.3.3"
version: "1.3.2"
file:
dependency: transitive
description:
Expand Down Expand Up @@ -279,10 +279,10 @@ packages:
dependency: transitive
description:
name: leak_tracker
sha256: "6bb818ecbdffe216e81182c2f0714a2e62b593f4a4f13098713ff1685dfb6ab0"
sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec
url: "https://pub.dev"
source: hosted
version: "10.0.9"
version: "10.0.8"
leak_tracker_flutter_testing:
dependency: transitive
description:
Expand Down Expand Up @@ -500,10 +500,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: ddfa8d30d89985b96407efce8acbdd124701f96741f2d981ca860662f1c0dc02
sha256: "0968250880a6c5fe7edc067ed0a13d4bae1577fe2771dcf3010d52c4a9d3ca14"
url: "https://pub.dev"
source: hosted
version: "15.0.0"
version: "14.3.1"
watcher:
dependency: transitive
description:
Expand Down
Loading