checkSubscription method

Future<bool> checkSubscription()

Implementation

Future<bool> checkSubscription() async {
  SharedPreferences sharedPreferences = await DeviceStorage().getInstance();
  String subscriptionData =
      sharedPreferences.getString(DeviceStorage.subscriptionData) ?? "";

  if (subscriptionData.isEmpty) {
    try {
      subscriptionData = await NetworkHandler.getSubcription();
    } catch (error) {
      subscriptionData = notsubscribed;
    }
  }
  await sharedPreferences.setString(
      DeviceStorage.subscriptionData, subscriptionData);
  if (subscriptionData.isEmpty || subscriptionData == notsubscribed) {
    return false;
  }
  return true;
}