Azure / azure-notificationhubs-dotnet

.NET SDK for Azure Notification Hubs
MIT License
70 stars 119 forks source link

[BUG] Notification Hub is not triggering events with latest version 10* of firebase_messaging in Flutter - works by using FCM direct though #204

Closed jruckert closed 2 years ago

jruckert commented 2 years ago

Describe the bug Using the latest FCM Messaging libraries in flutter, all events are not triggered when using the iOS platform (real device used). When using the FCM API direct with PostMan, all events are triggered as expected.

Exception or Stack Trace There is no exception/stack trace as this is performed via the Test Send via Azure Portal.

To Reproduce Create a flutter application using the latest sample provided by firebase_messaging https://github.com/FirebaseExtended/flutterfire/tree/master/packages/firebase_messaging/firebase_messaging/example Get the FCM token Put a breakpoint on the FirebaseMessaging.onMessage.listen event Register the FCM token with Notification Hub Send Test Message using the following payload - Note this is a data only event for background processing

{'aps':{'alert': null, 'badge': null, 'content-available':1}, 'data':{'type': 1, 'payload': 'test'}}

No Breakpoint hit


Using Postman to the following URL (same Apple certificate etc) and payload, breakpoints are being hit.

https://fcm.googleapis.com/fcm/send

{ "to":"****", "notification" : { "content_available" : true, "priority" : "high" }, "data" : { "sound" : "default", "body" : "test body", "title" : "test title", "content_available" : true, "priority" : "high" } }

Code Snippet Add the code snippet that causes the issue.

Expected behavior I believe (but probably completely wrong!) that it is caused by a missing element message_id - its expecting this to be provided by the Notification Hub payload

https://github.com/FirebaseExtended/flutterfire/blob/master/packages/firebase_messaging/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.m#L286

Screenshots If applicable, add screenshots to help explain your problem.

Setup (please complete the following information):

Additional context We cannot process any messages using the flutter framework since upgrading to the latest version and the Notification Hub, we can though use the FCM REST API's to successfully send and receive messages and payloads though.

Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

jruckert commented 2 years ago

For anyone else who encounters this - you need to include "gcm.message_id", "content-available" as part of every payload (both silent and non-silent notifications) you send through.