mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-28 06:28:41 +01:00
fix iOS send report issue
This commit is contained in:
@@ -8,6 +8,7 @@ import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
|
||||
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
|
||||
import 'package:cake_wallet/store/app_store.dart';
|
||||
import 'package:cake_wallet/utils/package_info.dart';
|
||||
import 'package:cake_wallet/utils/share_util.dart';
|
||||
import 'package:cake_wallet/utils/show_bar.dart';
|
||||
import 'package:cake_wallet/utils/show_pop_up.dart';
|
||||
import 'package:cw_core/root_dir.dart';
|
||||
@@ -17,12 +18,15 @@ import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_mailer/flutter_mailer.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class ExceptionHandler {
|
||||
static bool _hasError = false;
|
||||
static const _coolDownDurationInDays =
|
||||
bool.fromEnvironment('hasDevOptions', defaultValue: kDebugMode || kProfileMode) ? 0 : 7;
|
||||
static const _supportEmail = "support@cakewallet.com";
|
||||
static const _reportSubject = "Mobile App Issue";
|
||||
static File? _file;
|
||||
|
||||
static Future<void> _saveException(String? error, StackTrace? stackTrace,
|
||||
@@ -84,13 +88,14 @@ class ExceptionHandler {
|
||||
final bool canSend = await FlutterMailer.canSendMail();
|
||||
|
||||
if (Platform.isIOS && !canSend) {
|
||||
printV('Mail app is not available');
|
||||
printV("Mail app is not available, falling back to the share sheet");
|
||||
await _shareExceptionFile();
|
||||
return;
|
||||
}
|
||||
|
||||
final MailOptions mailOptions = MailOptions(
|
||||
subject: 'Mobile App Issue',
|
||||
recipients: ['support@cakewallet.com'],
|
||||
subject: _reportSubject,
|
||||
recipients: [_supportEmail],
|
||||
attachments: [_file!.path],
|
||||
);
|
||||
|
||||
@@ -108,6 +113,25 @@ class ExceptionHandler {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<void> _shareExceptionFile() async {
|
||||
final context = navigatorKey.currentContext;
|
||||
if (context == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final result = await ShareUtil.shareFile(
|
||||
filePath: _file!.path,
|
||||
fileName: "error.txt",
|
||||
context: context,
|
||||
subject: _reportSubject,
|
||||
text: _supportEmail,
|
||||
);
|
||||
|
||||
if (result.status == ShareResultStatus.success) {
|
||||
await _file!.writeAsString("", mode: FileMode.write);
|
||||
}
|
||||
}
|
||||
|
||||
static Future<void> resetLastPopupDate() async {
|
||||
final sharedPrefs = await SharedPreferences.getInstance();
|
||||
await sharedPrefs.setString(PreferencesKey.lastPopupDate, DateTime(1971).toString());
|
||||
|
||||
@@ -10,13 +10,15 @@ class ShareUtil {
|
||||
);
|
||||
}
|
||||
|
||||
static Future<void> shareFile({
|
||||
static Future<ShareResult> shareFile({
|
||||
required String filePath,
|
||||
required String fileName,
|
||||
required BuildContext context,
|
||||
}) async {
|
||||
String? subject,
|
||||
String? text,
|
||||
}) {
|
||||
const _mimeType = 'application/*';
|
||||
await Share.shareXFiles(
|
||||
return Share.shareXFiles(
|
||||
<XFile>[
|
||||
XFile(
|
||||
filePath,
|
||||
@@ -24,6 +26,8 @@ class ShareUtil {
|
||||
mimeType: _mimeType,
|
||||
)
|
||||
],
|
||||
subject: subject,
|
||||
text: text,
|
||||
sharePositionOrigin: _sharePosition(context),
|
||||
);
|
||||
}
|
||||
|
||||
+3
-3
@@ -1221,11 +1221,11 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: "."
|
||||
ref: "9c4ed111a9151a2bbfb9afe2c18a37599c6f84f3"
|
||||
resolved-ref: "9c4ed111a9151a2bbfb9afe2c18a37599c6f84f3"
|
||||
ref: "7280c3a17152be21be8bb2e172610dd8888049d2"
|
||||
resolved-ref: "7280c3a17152be21be8bb2e172610dd8888049d2"
|
||||
url: "https://github.com/taljacobson/flutter_mailer"
|
||||
source: git
|
||||
version: "3.0.0"
|
||||
version: "3.0.2"
|
||||
flutter_mobx:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
||||
+1
-1
@@ -77,7 +77,7 @@ dependencies:
|
||||
flutter_mailer:
|
||||
git:
|
||||
url: https://github.com/taljacobson/flutter_mailer
|
||||
ref: 9c4ed111a9151a2bbfb9afe2c18a37599c6f84f3
|
||||
ref: 7280c3a17152be21be8bb2e172610dd8888049d2
|
||||
device_info_plus: ^9.1.0
|
||||
base32: 2.1.3
|
||||
in_app_review: ^2.0.6
|
||||
|
||||
@@ -539,7 +539,7 @@ dependency_overrides:
|
||||
flutter_mailer:
|
||||
git:
|
||||
url: https://github.com/taljacobson/flutter_mailer
|
||||
ref: 9c4ed111a9151a2bbfb9afe2c18a37599c6f84f3
|
||||
ref: 7280c3a17152be21be8bb2e172610dd8888049d2
|
||||
flutter_mobx:
|
||||
git:
|
||||
url: https://github.com/mobxjs/mobx.dart
|
||||
|
||||
Reference in New Issue
Block a user