Description
I'm developing a .NET Maui Program to interface with Firebase Push Notifications. I'm using version 3.2.11 of Plugin.FirebasePushNotifications
I created a NotificationChannelFactory.cs that iterates through some channel properties I created that are shared with the cloud app that runs firebase.
public static NotificationChannelRequest[] GetChannels()
{
List<NotificationChannelRequest> channels = new();
foreach(var channel in CustomChannels.GetChannels())
{
var request = new NotificationChannelRequest
{
ChannelId = channel.Id,
ChannelName = channel.Name,
Description = channel.Description,
LockscreenVisibility = Android.App.NotificationVisibility.Private,
Importance = (Android.App.NotificationImportance) channel.Importance,
IsDefault = channel.Id == CustomChannels.DEFAULT_CHANNEL_ID,
};
channels.Add(request);
}
return channels.ToArray();
}
In MauiProgram.cs I have the following code to set up the push notifications and map the channels to my list of channels
.UseFirebasePushNotifications(o =>
{
#if ANDROID
o.Android.NotificationActivityType = typeof(MyMauiApp.MainActivity);
o.Android.DefaultNotificationImportance = Android.App.NotificationImportance.Default;
o.Android.NotificationChannels = NotificationChannelFactory.GetChannels();
On my main app page, I do call the following
await this.FirebasePushNotification.RegisterForPushNotificationsAsync();
this.FirebasePushNotification.SubscribeTopic(MyMainTopic);
for each(var topic in allTopics)
{
this.FirebasePushNotification.SubscribeTopic(topic);
}
FirebasePushNotification.NotificationReceived += HandlePushNotificationOnMainPage;
So far Push Notifications flow into the app appropriately. If in the Foreground the event handler receives the push. If in the background the Android UI displays the notification.
However, if I push to a specified Channel ID, it always goes to the default Channel.
I can look in the android app notification settings and I do see my custom channels, but the default is the only one that shows notifications. If I turn default off, I stop getting notifications. My goal is to allow the user to switch off certain channels and my app assign custom sounds per channel.
If I go into that Event Handler in the Foreground (HandlePushNotificationOnMainPage), and put a breakpoint when it's called and look at the contents of FirebasePushNotificationDataEventArgs e
I do see the Key "gcm.notification.android_channel_id" does have the correct value for the channel id and matches the one on the app side.
So for example, I have something similar to
Id: default, Name: Default Channel
Id: custom_1, Name: Custom Channel 1
Id: custom_2, Name: Custom Channel 2
And if I send a push notification via firebase with this Android Config with the ChannelId of custom_1, I see gcm.notification.android_channel_id does have custom_1 as the value, but it still goes to the Default Channel.
I can try to make a stub project if needed, but am I missing any steps in the configuration?
Description
I'm developing a .NET Maui Program to interface with Firebase Push Notifications. I'm using version 3.2.11 of Plugin.FirebasePushNotifications
I created a NotificationChannelFactory.cs that iterates through some channel properties I created that are shared with the cloud app that runs firebase.
In MauiProgram.cs I have the following code to set up the push notifications and map the channels to my list of channels
On my main app page, I do call the following
So far Push Notifications flow into the app appropriately. If in the Foreground the event handler receives the push. If in the background the Android UI displays the notification.
However, if I push to a specified Channel ID, it always goes to the default Channel.
I can look in the android app notification settings and I do see my custom channels, but the default is the only one that shows notifications. If I turn default off, I stop getting notifications. My goal is to allow the user to switch off certain channels and my app assign custom sounds per channel.
If I go into that Event Handler in the Foreground (HandlePushNotificationOnMainPage), and put a breakpoint when it's called and look at the contents of FirebasePushNotificationDataEventArgs e
I do see the Key "gcm.notification.android_channel_id" does have the correct value for the channel id and matches the one on the app side.
So for example, I have something similar to
Id: default, Name: Default Channel
Id: custom_1, Name: Custom Channel 1
Id: custom_2, Name: Custom Channel 2
And if I send a push notification via firebase with this Android Config with the ChannelId of custom_1, I see gcm.notification.android_channel_id does have custom_1 as the value, but it still goes to the Default Channel.
I can try to make a stub project if needed, but am I missing any steps in the configuration?