onBackgroundPush method

Future<void> onBackgroundPush(
  1. RemoteMessage message,
  2. String spStoreKey
)

Implementation

Future<void> onBackgroundPush(
    RemoteMessage message, String spStoreKey) async {
  await Firebase.initializeApp();
  var sp = await SharedPreferences.getInstance();
  await sp.reload();
  var list = sp.getStringList(spStoreKey) ?? [];
  list.add(jsonEncode(PushMsg(
          message.data['tag'],
          message.notification!.title ?? "",
          message.notification!.body ?? "",
          message.data['cabinetId'],
          message.data['error'],
          DateTime.now())
      .toJson()));
  await sp.setStringList(spStoreKey, list);
}