firebase / flutterfire

πŸ”₯ A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.71k stars 3.97k forks source link

πŸ› [firebase_messaging: ^14.7.10] Images not Displaying in Push Notifications from .NET Server Setup to Flutter App (Firebase Admin SDK) background state. #12139

Closed suhail600 closed 10 months ago

suhail600 commented 10 months ago

Description: I have successfully implemented push notifications from a .NET setup to a Flutter app using the Firebase Admin SDK. However, I am facing an issue with images not being displayed when the app is in the background and terminated state.

Issue Details:

Current Behavior: Push notifications are delivered successfully. Images are displayed when the Flutter app is in the foreground via flutter_local_notifications: ^16.3.0. both working via firebase console and firebase admin sdk .NET integration Images are not displayed when the Flutter app is in the background and terminated state. via firebase_messaging: ^14.7.10 via firebase console working but not working through firebase admin sdk .net integrration

Expected Behavior:

Images should be displayed in push notifications even when the Flutter app is in the background. Setup: .NET Server: Firebase Admin SDK Flutter App: Using firebase_messaging: ^14.7.10

Additional Information:

Images are visible in notifications when sent via the Firebase Console, confirming that the images are correctly uploaded and accessible. Code snippets for push notification implementation on the .NET server and Flutter app have been attached for reference.

Code Snippets:

.NET

var message = new MulticastMessage()
                        {
                            Tokens = tknBatch,
                            Notification = new Notification
                            {
                                Title = request.Title,
                                Body = request.BodyLink,
                                ImageUrl = "https://upload.wikimedia.org/wikipedia/commons/b/b6/Image_created_with_a_mobile_phone.png"

                            },
                            Android = new AndroidConfig
                            {
                                Notification = new AndroidNotification
                                {
                                    Title = request.Title,
                                    Body = request.BodyLink,
                                    ImageUrl = "https://upload.wikimedia.org/wikipedia/commons/b/b6/Image_created_with_a_mobile_phone.png"
                                },
                            },

                        };

Flutter

const AndroidNotificationChannel channel = AndroidNotificationChannel(
  'high_importance_channel', // id
  'High Importance Notifications', // title
  description: 'This channel is used for important notifications.',
  importance: Importance.high,
  playSound: true,
);         

Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
  await Firebase.initializeApp();
}               

 FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
danagbemava-nc commented 10 months ago

Hi @suhail600, what platform(s) are you seeing this issue on?

Also, can you try sending the notification using the js sdk to see if you still encounter this issue? You can use the plugin example app. It has a script that you can use to send the message. See https://github.com/firebase/flutterfire/blob/master/packages/firebase_messaging/firebase_messaging/example/scripts/send-message.js

suhail600 commented 10 months ago

its working now thanks.