You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And add the sound in the fcm push:
The fcm documentation mentions that only need to add the sound file name in the push for android, all good with that, used google documentation for it. Mentioning it as I understand that this forum is not for server side code.
Tried to create a channel with a default sound like this in the Android Main Activity:
private void CreateNotificationChannelIfNeeded()
{
if (Build.VERSION.SdkInt >= BuildVersionCodes.O)
{
CreateNotificationChannel();
}
}
private void CreateNotificationChannel()
{
var attributes = new AudioAttributes.Builder()
.SetUsage(AudioUsageKind.NotificationEvent | AudioUsageKind.Notification | AudioUsageKind.Alarm | AudioUsageKind.Media)
.Build();
var soundUri = Android.Net.Uri.Parse($"");
var channelId = "channelExample";
var notificationManager = (NotificationManager)GetSystemService(NotificationService);
var channel = new NotificationChannel(channelId, "channelExample", NotificationImportance.Max);
channel.SetSound(soundUri, attributes);
notificationManager.CreateNotificationChannel(channel);
}
protected override void OnNewIntent(Intent? intent)
{
base.OnNewIntent(intent);
}
But as in the example shows, I am not sure how to map the notification.wav sound in the path.
Searching in stack overflow or chatgpt got no information so far, only a few methods of Xamarin forms that are not in Maui.
At least I think this way works as how it is right now, I am not adding any sound, but the default sound is not appearing any more, so I think I am only missing the correct mapping
Does any one know how to enable the sound for my notification?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi, is the first time that I am implementing push notifications for an app.
And the documentation in Maui is not that complete.
I got so far to use the push Notifications and access the delegate events in both iOS and Android.
But I have a requirement to use a custom sound file when the notification appears in the device, I am trying first in android this.
But even if I add
My sound file in the Android project under Resources/raw
Example of my csproj:
And add the sound in the fcm push:
The fcm documentation mentions that only need to add the sound file name in the push for android, all good with that, used google documentation for it. Mentioning it as I understand that this forum is not for server side code.
https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages
The sound is not changing from the default.
Tried to create a channel with a default sound like this in the Android Main Activity:
But as in the example shows, I am not sure how to map the notification.wav sound in the path.
Searching in stack overflow or chatgpt got no information so far, only a few methods of Xamarin forms that are not in Maui.
At least I think this way works as how it is right now, I am not adding any sound, but the default sound is not appearing any more, so I think I am only missing the correct mapping
Does any one know how to enable the sound for my notification?
Beta Was this translation helpful? Give feedback.
All reactions