You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I use Flutter 1.x, I successfully send push message from node.js server to my flutter app using firebase_messaging:7.0.3
I sent a token to server with below code.
FirebaseMessaging _firebaseMessaging;
_firebaseMessaging.getToken().then((String notiToken) {
// Code to send token to server
});
I migrated my flutter project to v2.x. I had to use firebase_messaging:10.0.4. And I changed my code about firebase_messaging.
FirebaseMessaging.instance
.getInitialMessage()
.then((RemoteMessage? message) {
if (message != null) {
// show notification
}
});
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
RemoteNotification? notification = message.notification;
AndroidNotification? android = message.notification?.android;
if (notification != null && android != null && !kIsWeb) {
flutterLocalNotificationsPlugin!.show(
notification.hashCode,
notification.title,
notification.body,
NotificationDetails(
android: AndroidNotificationDetails(
channel!.id,
channel!.name,
channel!.description,
// TODO add a proper drawable resource to android, for now using
// one that already exists in example app.
icon: 'launch_background',
),
));
}
});
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
print('A new onMessageOpenedApp event was published!');
// show notification
});
FirebaseMessaging.instance.getToken().then((String? token) {
print("firebaseMessaging token : $token");
// Code to send token to server
});
I have successfully sent the token to the server.
However, when a push notification is sent to node.js using that token, a message does not come as in v1.x.
Is the token wrong? I can't tell if the code is wrong.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
When I use Flutter 1.x, I successfully send push message from node.js server to my flutter app using firebase_messaging:7.0.3
I sent a token to server with below code.
I migrated my flutter project to v2.x. I had to use firebase_messaging:10.0.4. And I changed my code about firebase_messaging.
I have successfully sent the token to the server.
However, when a push notification is sent to node.js using that token, a message does not come as in v1.x.
Is the token wrong? I can't tell if the code is wrong.
Please help.
Beta Was this translation helpful? Give feedback.
All reactions