Open
Description
Is there an existing issue for this?
- I have searched the existing issues.
Which plugins are affected?
Messaging
Which platforms are affected?
macOS
Description
This code :
FirebaseMessaging.onMessage.listen((RemoteMessage event) {
print("Message received in app : ${event.toMap()}");
});
Seems to not log anything when receiving a Push notification when the app is in the foreground on MacOS.
It works fine on Android / iOS but not on my Mac (on the same app with the same server code sending the same push notification)
Reproducing the issue
- Create a sample app or use the plugin example if it allows it
- Use this code :
Future<void> initialize() async {
NotificationSettings settings = await FirebaseMessaging.instance
.requestPermission(sound: true, carPlay: true);
if (settings.authorizationStatus == AuthorizationStatus.authorized ||
settings.authorizationStatus == AuthorizationStatus.provisional) {
_getToken();
print("Initializing the message listener...");
FirebaseMessaging.onMessage.listen((RemoteMessage event) {
print("Message received in app : ${event.toMap()}");
});
}
}
Future<void> _getToken() async {
String? apnsToken = await FirebaseMessaging.instance.getAPNSToken();
print("APNS Token : $apnsToken on ${Platform.operatingSystem}");
String token = await FirebaseMessaging.instance.getToken() ?? "";
print("FCM Token : $token on ${Platform.operatingSystem}");
}
- Send a push notification from the server (to the tokens of the MacOS target, not from FCM dashboard)
- See that you have no log "Message received in app"
Firebase Core version
3.13.0
Flutter Version
3.29.3
Relevant Log Output
Flutter dependencies
Expand Flutter dependencies
snippet
Replace this line with the contents of your `flutter pub deps -- --style=compact`.
Additional context and comments
No response