|
|
|
@ -1,19 +1,17 @@
|
|
|
|
// Dart imports:
|
|
|
|
// Dart imports:
|
|
|
|
import 'dart:io';
|
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
|
|
|
|
// Flutter imports:
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Package imports:
|
|
|
|
// Package imports:
|
|
|
|
import 'package:collection/collection.dart';
|
|
|
|
import 'package:collection/collection.dart';
|
|
|
|
import 'package:purchases_flutter/purchases_flutter.dart';
|
|
|
|
|
|
|
|
import 'package:sentry_flutter/sentry_flutter.dart';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Project imports:
|
|
|
|
// Project imports:
|
|
|
|
import 'package:fluffychat/pangea/config/environment.dart';
|
|
|
|
import 'package:fluffychat/pangea/config/environment.dart';
|
|
|
|
import 'package:fluffychat/pangea/controllers/subscription_controller.dart';
|
|
|
|
import 'package:fluffychat/pangea/controllers/subscription_controller.dart';
|
|
|
|
import 'package:fluffychat/pangea/models/base_subscription_info.dart';
|
|
|
|
import 'package:fluffychat/pangea/models/base_subscription_info.dart';
|
|
|
|
import 'package:fluffychat/pangea/utils/error_handler.dart';
|
|
|
|
import 'package:fluffychat/pangea/utils/error_handler.dart';
|
|
|
|
|
|
|
|
// Flutter imports:
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
import 'package:purchases_flutter/purchases_flutter.dart';
|
|
|
|
|
|
|
|
import 'package:sentry_flutter/sentry_flutter.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class MobileSubscriptionInfo extends SubscriptionInfo {
|
|
|
|
class MobileSubscriptionInfo extends SubscriptionInfo {
|
|
|
|
MobileSubscriptionInfo({required super.pangeaController}) : super();
|
|
|
|
MobileSubscriptionInfo({required super.pangeaController}) : super();
|
|
|
|
@ -161,17 +159,22 @@ class MobileSubscriptionInfo extends SubscriptionInfo {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
final List<EntitlementInfo> activeEntitlements = info
|
|
|
|
final List<EntitlementInfo> activeEntitlements =
|
|
|
|
.entitlements.all.entries
|
|
|
|
info.entitlements.all.entries
|
|
|
|
.where((MapEntry<String, EntitlementInfo> entry) =>
|
|
|
|
.where(
|
|
|
|
|
|
|
|
(MapEntry<String, EntitlementInfo> entry) =>
|
|
|
|
entry.value.expirationDate == null ||
|
|
|
|
entry.value.expirationDate == null ||
|
|
|
|
DateTime.parse(entry.value.expirationDate!).isAfter(DateTime.now()))
|
|
|
|
DateTime.parse(entry.value.expirationDate!)
|
|
|
|
|
|
|
|
.isAfter(DateTime.now()),
|
|
|
|
|
|
|
|
)
|
|
|
|
.map((MapEntry<String, EntitlementInfo> entry) => entry.value)
|
|
|
|
.map((MapEntry<String, EntitlementInfo> entry) => entry.value)
|
|
|
|
.toList();
|
|
|
|
.toList();
|
|
|
|
|
|
|
|
|
|
|
|
allEntitlements = info.entitlements.all.entries
|
|
|
|
allEntitlements = info.entitlements.all.entries
|
|
|
|
.map((MapEntry<String, EntitlementInfo> entry) =>
|
|
|
|
.map(
|
|
|
|
entry.value.productIdentifier)
|
|
|
|
(MapEntry<String, EntitlementInfo> entry) =>
|
|
|
|
|
|
|
|
entry.value.productIdentifier,
|
|
|
|
|
|
|
|
)
|
|
|
|
.cast<String>()
|
|
|
|
.cast<String>()
|
|
|
|
.toList();
|
|
|
|
.toList();
|
|
|
|
|
|
|
|
|
|
|
|
@ -181,7 +184,9 @@ class MobileSubscriptionInfo extends SubscriptionInfo {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
} else if (activeEntitlements.isEmpty) {
|
|
|
|
} else if (activeEntitlements.isEmpty) {
|
|
|
|
debugPrint("User has no active entitlements");
|
|
|
|
debugPrint("User has no active entitlements");
|
|
|
|
|
|
|
|
if (!isNewUserTrial) {
|
|
|
|
resetSubscription();
|
|
|
|
resetSubscription();
|
|
|
|
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
final EntitlementInfo activeEntitlement = activeEntitlements[0];
|
|
|
|
final EntitlementInfo activeEntitlement = activeEntitlements[0];
|
|
|
|
|