相关疑难解决方法(0)

未处理的异常:NoSuchMethodError:在 null 上调用了方法“toRawHandle”

我在我的 Flutter 应用程序中使用firebase_messaging库进行 Firebase 推送通知。

目前我的 firebase_messaging 版本是firebase_messaging: ^5.1.5最近更新的最新版本。

我正在尝试在后台以及应用程序终止时接收通知。

我已经按照 firebase_messaging 文档中提到的所有步骤进行了操作,但不幸的是,我在 flutter 中遇到了上述错误。

这是我在 dart 中的通知处理程序类

通知处理程序.dart

import 'dart:async';
import 'dart:io';
import 'dart:math';

import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:path_provider/path_provider.dart';
import 'package:http/http.dart' as http;

class NotificationHandler {
  FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin;
  FirebaseMessaging _fcm = FirebaseMessaging();
  StreamSubscription iosSubscription;
  static final NotificationHandler _singleton =
      new NotificationHandler._internal();

  factory NotificationHandler() {
    return _singleton;
  }
  NotificationHandler._internal();

  Future<dynamic> myBackgroundMessageHandler(
      Map<String, dynamic> message) async {
    print("onLaunch: $message");
    _showBigPictureNotification(message);
    // Or do other …
Run Code Online (Sandbox Code Playgroud)

android flutter firebase-cloud-messaging

10
推荐指数
3
解决办法
2万
查看次数