flutter-webrtc / callkeep

iOS CallKit and Android ConnectionService for Flutter
MIT License
130 stars 139 forks source link

The latest Cloud Messaging cannot be used #133

Open k-y-1202 opened 2 years ago

k-y-1202 commented 2 years ago

I used firebase_messaging: ^11.2.6 .

The example uses 7.0.0, but the usage of FirebaseMessaging.onBackgroundMessage is very different and cannot be implemented.

In particular, the type of RemoteMessage has changed, and the payload cannot be obtained.

Can anyone tell me?

efraespada commented 2 years ago

You can use this for work with the payload:

extension RemoteMessageExt on RemoteMessage {
  Map<String, dynamic> getContent() {
    return jsonDecode(data['content']);
  }

  Map<String, dynamic> payload() {
    return getContent()['payload'];
  }
}

It is what I currently use with the latest version of FCM.