首页 > 解决方案 > 推送 Notificatblanion Firebase 失败 - 错误消息为空

问题描述

我收到 Pushnotification 的空白错误消息 - firebase

除推送通知外,所有通知均有效。我们需要在 Firebase 中启用任何特定设置吗?

我放置在提供推送通知的大部分颤振设置下方。

class PushNotificationsBloc
    extends Bloc<PushNotificationsEvent, PushNotificationsState> {
  final UserDataRepository userDataRepository;

  PushNotificationsBloc({this.userDataRepository})
      : super(PushNotificationsInitial());

  @override
  Stream<PushNotificationsState> mapEventToState(
    PushNotificationsEvent event,
  ) async* {
    if (event is SendNewNotification) {
      yield* mapSendNewNotificationToState(event.map);
    }
  }

  Stream<PushNotificationsState> mapSendNewNotificationToState(Map map) async* {
    yield SendNewNotificationInProgressState();
    try {
      String res = await userDataRepository.sendNewNotification(map);
      if (res != null) {
        yield SendNewNotificationCompletedState(res);
      } else {
        yield SendNewNotificationFailedState();
      }
    } catch (e) {
      print(e);
      yield SendNewNotificationFailedState();
    }
  }
}

@immutable
abstract class PushNotificationsState {}

class PushNotificationsInitial extends PushNotificationsState {}

class SendNewNotificationCompletedState extends PushNotificationsState {
  final String res;

  SendNewNotificationCompletedState(this.res);
}

class SendNewNotificationFailedState extends PushNotificationsState {}

class SendNewNotificationInProgressState extends PushNotificationsState {}

标签: firebaseflutterpush-notification

解决方案


推荐阅读