firebase / firebase/firebase-admin-dotnet

Execute "onMessageReceived" on background

Open
#326 3 comments 0 reactions 1 assignee Claimed by @chong-shao View on GitHub
api: messaging
Dominant language
C#
Stars
408
Forks
146
Avg merge
22h 7m
Merged PRs (30d)
1

Description

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

* I like to send a "data message" throw this nuget (no notification), so the "onMessageReceived" method was call on android in even in background.
* Actually, I use HTTP legacy URI : https://fcm.googleapis.com/fcm/send and I'm able to send "data message" and "notification message"
* I try to use "HTTP v1" instead, but I can't send "data message", I always receive a "notification message"

### [REQUIRED] Step 2: Describe your environment

* Operating System version: ubuntu 22.04
* Firebase SDK version: 2.3.0
* Firebase Product: messaging
* .NET version: net6.0
* OS: linux

### [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() { }
};
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() { }
};
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 ?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.