firebase / firebase-admin-dotnet

Firebase Admin .NET SDK
https://firebase.google.com/docs/admin/setup
Apache License 2.0
357 stars 129 forks source link

Execute "onMessageReceived" on background #326

Open mickjol opened 2 years ago

mickjol commented 2 years ago

[READ] Step 1: Are you in the right place?

[REQUIRED] Step 2: Describe your environment

[REQUIRED] Step 3: Describe the problem

Steps to reproduce:

Send a message with :

var message = new Message()
{
    Token = myToken,
    Notification = new Notification
    {
        Body = notification.Message.GetLanguage(device.DeviceLanguage),
        Title = notification.Title.GetLanguage(device.DeviceLanguage),
    },
    Android = new AndroidConfig
    {
        TimeToLive = TimeSpan.FromHours(1),
        Priority = Priority.High,
        Notification = new AndroidNotification
        {
            ChannelId = GetAndroidChannelId("alertChannel", soundName)
        }
    },
    Data = new Dictionary<string, string>() { }
};
var fcmResponse = await FirebaseMessaging.DefaultInstance.SendAsync(message);

I receive a "notification message" :)

var message = new Message()
{
    Token = myToken,
    Android = new AndroidConfig
    {
        TimeToLive = TimeSpan.FromHours(1),
        Priority = Priority.High,
        Notification = new AndroidNotification
        {
            ChannelId = GetAndroidChannelId("alertChannel", soundName)
        }
    },
    Data = new Dictionary<string, string>() { }
};
var fcmResponse = await FirebaseMessaging.DefaultInstance.SendAsync(message);

I receive a "notification message" not a "data message" :(

I aslo try to force the Notification property as null. But I had the same result

var message = new Message()
{
    Token = myToken,
    Notification = null,
...

There is something I can do ?

iamkinetic commented 2 years ago

@chong-shao Is there any follow up about this problem?

philipperobertgh commented 2 years ago

Same problem for me. Is there any solution available ?

Josbleuet commented 2 years ago

It seams that I have the same issue, any news ?