当应用程序在前台时,云消息 onMessage 回调永远不会被调用,但 onResume 和 onLaunch 会被调用吗?

Cloud Messaging onMessage callback never gets called when app is in the foreground but onResume and onLaunch do get called?

我实现了 firebase 云消息传递并遵循了以下教程 https://www.youtube.com/watch?time_continue=304&v=2TSm2YGBT1s&feature=emb_logo。我大部分时间都在使用它。每当应用程序在后台或关闭时,我都会收到通知,它会打开应用程序并执行回调 onResume 或 onLaunch。

但我似乎无法使 onMessage 回调正常工作。每当应用程序位于前台并且我发送通知时,不会调用 onMessage 吗?我的控制台收到以下日志

E/FlutterFcmService(18141): Fatal: failed to find callback
W/FirebaseMessaging(18141): Unable to log event: analytics library is missing
W/FirebaseMessaging(18141): Unable to log event: analytics library is missing

我也没有看到 onBackgroundMessage 被调用。

通知服务

class CloudMessagingService extends NotificationService
{
  final FirebaseMessaging firebaseMessaging = FirebaseMessaging();

  CloudMessagingService()
  {
    if(Platform.isIOS)
      firebaseMessaging.requestNotificationPermissions(IosNotificationSettings());

    firebaseMessaging.configure(
      onMessage: (Map<String, dynamic> message) async {
        print('I have a cloud messaging message yay');
        print('onMessage: $message');
      },
      onBackgroundMessage: (Map<String, dynamic> message) async {
        print('onBackgroundMessage: $message');
      },
      onLaunch: (Map<String, dynamic> message) async {
        print('onLaunch: $message');
      },
      onResume: (Map<String, dynamic> message) async {
        print('onResume: $message');
      },
    );
  }

  Future<void> sendNotificationToGroup(GroupModel group, NotificationType type)
  {
    print('Send ${type.valueString} notification to ${group.id}');
    return null;
  }
}

我正在使用 Pixel 3XL

在 android 模拟器上进行测试

于是仔细查看了文档,发现

Note: When you are debugging on Android, use a device or AVD with Google Play services. Otherwise you will not be able to authenticate.

切换到支持 Playstore 的设备后调用了 onMessage 回调!