mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-27 05:59:38 +00:00
a472527c6f
* Add app reveiw on transactions and exchange * Update Onramper page * Fix issues in popup review
29 lines
975 B
Dart
29 lines
975 B
Dart
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();
|
|
}
|
|
}
|
|
}
|