Azure / azure-notificationhubs-dotnet

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

[BUG] GCM HTTP protocol parameters not passed on ? #229

Open tijeanhimself opened 2 years ago

tijeanhimself commented 2 years ago

Describe the bug We already have GCM/FCM setup up and we are able to send notifications to both iOS and Android devices. More specifically data-only notifications where we add the parameters ( priority, content_available, collapse_key )

Especially the content_available parameter is crucial when the phone is an iOS device and in order to receive the data-only notifications when the app is in the background. But behaviour seems to be different between https://fcm.googleapis.com/fcm/send call and Portal -> Azure Notification Hub -> Test Send ( or SendFcmNativeNotificationAsync )

Working Case Everything works as expected when I use the https://fcm.googleapis.com/fcm/send call. So we have the following message for example:

{
    "to": "…REDACTED_THE_ID...",
    "collapse_key" : "123456769",
    "priority": "high",
    "content_available":true,
    "time_to_live": 600,
    "data": {
        "content": {
            "id": "9d2b0228-4d0d-4c23-8b49-01a698857710"
        },
        "dataType": "terminal"
    }
}

Issue To Reproduce

But when we use the following message in the Portal -> Azure Notification Hub -> Test Send

Azure Notifications hub approves the message and confirms that message was successfully sent. But then nothing arrives on the iOS smartphone, it seems as if the content_available parameter is not taken into account. If I add a valid “notification” field (which makes it a NON- data-only notifications ) then it arrives.

{
    "collapse_key" : "123456769",
    "priority": "high",
    "content_available":true,
    "time_to_live": 600,
    "data": {
        "content": {
            "id": "9d2b0228-4d0d-4c23-8b49-01a698857710"
        },
        "dataType": "terminal"
    }
}

Code Snippet I had the same issue when using SendFcmNativeNotificationAsync with similar payloads.

Expected behavior Both environments should have the same behavior