clearOldVersionNotification static method

void clearOldVersionNotification({
  1. required String tag,
  2. required String newTag,
})

Implementation

static void clearOldVersionNotification({
  required String tag,
  required String newTag,
}) {
  final String rawString = Preferences.getString(
    '${ApConstants.packageName}.'
        'course_notify_data_$tag',
    '',
  );
  debugPrint(rawString);
  if (rawString.isNotEmpty) {
    final CourseNotifyData courseNotifyData =
        CourseNotifyData.fromRawJson(rawString);
    for (final CourseNotify element in courseNotifyData.data) {
      NotificationUtils.cancelCourseNotify(id: element.id);
    }
    courseNotifyData.data.clear();
    courseNotifyData.tag = newTag;
    courseNotifyData.save();
  }
  Preferences.remove('${ApConstants.packageName}.course_notify_data_$tag');
}