-
Notifications
You must be signed in to change notification settings - Fork 18
Updated nocodes logic and dart version #414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
0168aa6
9e07269
66bcf79
6466c4d
99e7a97
21784f1
505c587
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,4 +7,8 @@ | |
| build/ | ||
| .idea | ||
|
|
||
| lib/*.jar | ||
| lib/*.jar | ||
|
|
||
| # Local configuration files | ||
| local.properties | ||
| **/local.properties | ||
This file was deleted.
| 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'; | ||
| } | ||
| } | ||
|
|
| 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'; | ||
|
|
@@ -36,7 +37,10 @@ class NoCodesInternal implements NoCodes { | |
| Constants.kSource: Constants.sdkSource, | ||
| if (config.proxyUrl != null) Constants.kProxyUrl: config.proxyUrl, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if we add without the null-check, will it break up?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
||
| }); | ||
| } | ||
|
|
||
| @override | ||
|
|
@@ -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 | ||
|
|
@@ -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 | ||
|
|
@@ -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, | ||
| ); | ||
| } | ||
SpertsyanKM marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.