首页 > 解决方案 > Firebase 推送通知突然停止在 Flutter 应用程序中工作

问题描述

我的颤振应用程序在两者上都正确接收了firebase推送通知iOSAndroid但是今天,出乎意料的是,它停止接收推送通知,尽管通过发送推送的响应cURL返回了成功消息。我正在按照FlutterFire 指南实施 Firebase 推送通知。应用程序在前台和后台模式下均未收到推送。

以下是我function的几个小时前工作得很好。

  Future<void> _configureFcm() async {
    _firebaseMessaging = FirebaseMessaging.instance;
    _userLoginModel = await Others.getUserLoginStatus();
    _subscription = _firebaseMessaging.onTokenRefresh.listen((token) async {
      _firebaseHelper.saveTokenToFirebaseServer(
        token,
        _userLoginModel.userId,
        widget._userType,
      );
    });
    _firebaseHelper.saveTokenToFirebaseServer(
      await _firebaseMessaging.getToken(),
      _userLoginModel.userId,
      widget._userType,
    );
    await _firebaseMessaging.requestPermission(
      alert: true,
      announcement: false,
      badge: true,
      carPlay: false,
      criticalAlert: false,
      provisional: false,
      sound: true,
    );

    FirebaseMessaging.onMessage.listen((RemoteMessage message) async {
      print('received notification');
     });
  }

常见问题

  1. 这个功能以前有效吗?==> 是的,是的
  2. 您是否对与通知相关的任何代码进行了任何更改?==> 不,事实上我根本没有对我的代码进行任何更改
  3. 你试过真机吗?==> 是的,我尝试过真实的Android设备iOS,它们以前工作得很好,但现在不行了
  4. 您是否检查了与 Firebase 应用程序的连接?==> 是的,我做到了,Cloud Firestore 和 Auth 等其他服务运行良好
  5. 你试过了flutter clean吗?==> 是的,我做到了

标签: firebaseflutterdartpush-notificationfirebase-cloud-messaging

解决方案


推荐阅读