CW-33 Add app review after successful transactions and exchange (#864)

* Add app reveiw on transactions and exchange

* Update Onramper page

* Fix issues in popup review
This commit is contained in:
Godwin Asuquo 2023-04-17 21:06:58 +03:00 committed by GitHub
parent 4a203a43c8
commit a472527c6f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 44 additions and 6 deletions

View file

@ -31,6 +31,8 @@ class PreferencesKey {
static const pinTimeOutDuration = 'pin_timeout_duration'; static const pinTimeOutDuration = 'pin_timeout_duration';
static const lastAuthTimeMilliseconds = 'last_auth_time_milliseconds'; static const lastAuthTimeMilliseconds = 'last_auth_time_milliseconds';
static const lastPopupDate = 'last_popup_date'; static const lastPopupDate = 'last_popup_date';
static const lastAppReviewDate = 'last_app_review_date';
static String moneroWalletUpdateV1Key(String name) static String moneroWalletUpdateV1Key(String name)

View file

@ -1,4 +1,5 @@
import 'dart:ui'; import 'dart:ui';
import 'package:cake_wallet/utils/request_review_handler.dart';
import 'package:mobx/mobx.dart'; import 'package:mobx/mobx.dart';
import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -351,8 +352,10 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
right: 24, right: 24,
bottom: 24, bottom: 24,
child: PrimaryButton( child: PrimaryButton(
onPressed: () => onPressed: () {
Navigator.of(popupContext).pop(), Navigator.of(popupContext).pop();
RequestReviewHandler.requestReview();
},
text: S.of(popupContext).send_got_it, text: S.of(popupContext).send_got_it,
color: Theme.of(popupContext) color: Theme.of(popupContext)
.accentTextTheme! .accentTextTheme!

View file

@ -6,6 +6,7 @@ import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
import 'package:cake_wallet/src/widgets/picker.dart'; import 'package:cake_wallet/src/widgets/picker.dart';
import 'package:cake_wallet/src/widgets/template_tile.dart'; import 'package:cake_wallet/src/widgets/template_tile.dart';
import 'package:cake_wallet/utils/payment_request.dart'; import 'package:cake_wallet/utils/payment_request.dart';
import 'package:cake_wallet/utils/request_review_handler.dart';
import 'package:cake_wallet/utils/responsive_layout_util.dart'; import 'package:cake_wallet/utils/responsive_layout_util.dart';
import 'package:cake_wallet/view_model/send/output.dart'; import 'package:cake_wallet/view_model/send/output.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -383,8 +384,10 @@ class SendPage extends BasePage {
alertContent: S.of(context).send_success( alertContent: S.of(context).send_success(
sendViewModel.selectedCryptoCurrency.toString()), sendViewModel.selectedCryptoCurrency.toString()),
buttonText: S.of(context).ok, buttonText: S.of(context).ok,
buttonAction: () => buttonAction: () {
Navigator.of(context).pop()); Navigator.of(context).pop();
RequestReviewHandler.requestReview();
});
} }
return Offstage(); return Offstage();

View file

@ -0,0 +1,29 @@
import 'package:cake_wallet/entities/preferences_key.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:in_app_review/in_app_review.dart';
class RequestReviewHandler {
static const _coolDownDurationInDays = 30;
static void requestReview() async {
final sharedPrefs = await SharedPreferences.getInstance();
final lastReviewRequestDate =
DateTime.tryParse(sharedPrefs.getString(PreferencesKey.lastAppReviewDate) ?? '') ??
DateTime.now().subtract(Duration(days: _coolDownDurationInDays + 1));
final durationSinceLastRequest = DateTime.now().difference(lastReviewRequestDate).inDays;
if (durationSinceLastRequest < _coolDownDurationInDays) {
return;
}
sharedPrefs.setString(PreferencesKey.lastAppReviewDate, DateTime.now().toString());
final InAppReview inAppReview = InAppReview.instance;
if (await inAppReview.isAvailable()) {
inAppReview.requestReview();
}
}
}

View file

@ -67,6 +67,7 @@ dependencies:
wakelock: ^0.6.2 wakelock: ^0.6.2
flutter_mailer: ^2.0.2 flutter_mailer: ^2.0.2
device_info_plus: 8.1.0 device_info_plus: 8.1.0
in_app_review: ^2.0.6
cake_backup: cake_backup:
git: git:
url: https://github.com/cake-tech/cake_backup.git url: https://github.com/cake-tech/cake_backup.git