Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@
build/
.idea

lib/*.jar
lib/*.jar

# Local configuration files
local.properties
**/local.properties
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.0.0"
implementation "io.qonversion:sandwich:7.1.0"
implementation 'com.google.code.gson:gson:2.9.0'
}
8 changes: 0 additions & 8 deletions example/android/app/local.properties

This file was deleted.

9 changes: 8 additions & 1 deletion ios/Classes/FlutterError+Custom.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,21 @@ extension FlutterError {
details: "")

private static func mapSandwichError(_ error: SandwichError, errorCode: String, errorMessage: String? = nil) -> FlutterError {
var message = ""

if let errorMessage = errorMessage {
message = errorMessage + ". "
}
message += error.details

var details = "Qonversion Error Code: \(error.code)"

if let additionalMessage = error.additionalMessage {
details = "\(details). Additional Message: \(additionalMessage)"
}

return FlutterError(code: errorCode,
message: error.details,
message: message,
details: details)
}
}
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.0.0"
s.dependency "QonversionSandwich", "7.1.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
1 change: 1 addition & 0 deletions lib/qonversion_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export 'src/dto/purchase_options_builder.dart';
export 'src/dto/purchase_update_model.dart';
export 'src/dto/purchase_update_policy.dart';
export 'src/dto/purchase_exception.dart';
export 'src/dto/qonversion_exception.dart';
export 'src/dto/subscription_period.dart';
export 'src/dto/qonversion_error.dart';
export 'src/dto/qonversion_error_code.dart';
Expand Down
27 changes: 27 additions & 0 deletions lib/src/dto/qonversion_exception.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import 'qonversion_error_code.dart';

/// General Qonversion exception for all non-purchase related errors
class QonversionException implements Exception {
/// Qonversion Error Code
///
/// See more in [documentation](https://documentation.qonversion.io/docs/handling-errors)
final String code;

/// Error description
final String message;

/// Additional error info
final String? details;

const QonversionException(
this.code,
this.message,
this.details,
);

@override
String toString() {
return 'QonversionException.\nCode: $code, Description: $message, Additional Message: $details';
}
}

44 changes: 36 additions & 8 deletions lib/src/internal/nocodes_internal.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:async';
import 'dart:io';
import 'package:flutter/services.dart';
import 'package:qonversion_flutter/src/dto/qonversion_exception.dart';
import 'package:qonversion_flutter/src/internal/qonversion_internal.dart';
import '../dto/nocodes_events.dart';
import '../dto/presentation_config.dart';
Expand Down Expand Up @@ -36,7 +37,10 @@ class NoCodesInternal implements NoCodes {
Constants.kSource: Constants.sdkSource,
if (config.proxyUrl != null) Constants.kProxyUrl: config.proxyUrl,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we add without the null-check, will it break up?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to check to avoid unnecessary behavior

};
_channel.invokeMethod(Constants.mInitializeNoCodes, args);
// Initialize is fire-and-forget, errors will be handled in subsequent calls
_channel.invokeMethod(Constants.mInitializeNoCodes, args).catchError((error) {
// Silently ignore initialization errors
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's log them at least

});
}

@override
Expand Down Expand Up @@ -132,11 +136,19 @@ class NoCodesInternal implements NoCodes {
return;
}

final args = {
Constants.kConfig: config.toMap(),
if (contextKey != null) Constants.kContextKey: contextKey,
};
await _channel.invokeMethod(Constants.mSetScreenPresentationConfig, args);
try {
final args = {
Constants.kConfig: config.toMap(),
if (contextKey != null) Constants.kContextKey: contextKey,
};
await _channel.invokeMethod(Constants.mSetScreenPresentationConfig, args);
} on PlatformException catch (e) {
throw QonversionException(
e.code,
e.message ?? "",
e.details,
);
}
}

@override
Expand All @@ -145,7 +157,15 @@ class NoCodesInternal implements NoCodes {
return;
}

await _channel.invokeMethod(Constants.mShowNoCodesScreen, {Constants.kContextKey: contextKey});
try {
await _channel.invokeMethod(Constants.mShowNoCodesScreen, {Constants.kContextKey: contextKey});
} on PlatformException catch (e) {
throw QonversionException(
e.code,
e.message ?? "",
e.details,
);
}
}

@override
Expand All @@ -154,6 +174,14 @@ class NoCodesInternal implements NoCodes {
return;
}

await _channel.invokeMethod(Constants.mCloseNoCodes);
try {
await _channel.invokeMethod(Constants.mCloseNoCodes);
} on PlatformException catch (e) {
throw QonversionException(
e.code,
e.message ?? "",
e.details,
);
}
}
}
Loading
Loading