From 6a4a74db7729d91b2185c2bfe3192431a01aecb1 Mon Sep 17 00:00:00 2001 From: reasje Date: Thu, 19 Oct 2023 10:46:00 +0330 Subject: [PATCH] fix: Launch email app if not logged in IOS --- assets/flutter_i18n/en.json | 3 ++- .../recovery_phrase_base_presenter.dart | 24 +++++++++++++------ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/assets/flutter_i18n/en.json b/assets/flutter_i18n/en.json index 97bf7f83..0add92cf 100644 --- a/assets/flutter_i18n/en.json +++ b/assets/flutter_i18n/en.json @@ -299,5 +299,6 @@ "removing_account": "Removing account", "removing_account_warning": "Are you sure you want to remove this account?", "remove": "Remove", - "duplicate_account_import_notice": "The account you are trying to import is a duplicate" + "duplicate_account_import_notice": "The account you are trying to import is a duplicate", + "unable_to_launch_email_app": "Unable to launch email app" } \ No newline at end of file diff --git a/lib/features/splash/secure_recovery_phrase/presentation/recovery_phrase_base/recovery_phrase_base_presenter.dart b/lib/features/splash/secure_recovery_phrase/presentation/recovery_phrase_base/recovery_phrase_base_presenter.dart index 6a46efc4..742a1756 100644 --- a/lib/features/splash/secure_recovery_phrase/presentation/recovery_phrase_base/recovery_phrase_base_presenter.dart +++ b/lib/features/splash/secure_recovery_phrase/presentation/recovery_phrase_base/recovery_phrase_base_presenter.dart @@ -114,15 +114,25 @@ abstract class RecoveryPhraseBasePresenter ); try { - MailerResponse sendResult = await FlutterMailer.send(email); - // only [ios] can return sent | saved | cancelled - // [android] will return android there is no way of knowing on android - // if the intent was sent saved or even cancelled. - if (MailerResponse.cancelled != sendResult) { - nextProcess(settingsFlow, res['phrases']); + bool canSend = await FlutterMailer.canSendMail(); + + if (Platform.isIOS && !canSend) { + await Utils.launchEmailApp(); + } else { + MailerResponse sendResult = await FlutterMailer.send(email); + // only [ios] can return sent | saved | cancelled + // [android] will return android there is no way of knowing on android + // if the intent was sent saved or even cancelled. + if (MailerResponse.cancelled != sendResult) { + nextProcess(settingsFlow, res['phrases']); + } } } catch (e, s) { - addError(e, s); + if (e == 'unable_to_launch_email_app') { + addError(translate('unable_to_launch_email_app')); + } else { + addError(e, s); + } } } }