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
I am porting over a Xamarin project (native iOS and Android).
I cannot get the Android to play the custom sound file. iOS is working fine.
I have an mp3 file (notify2.mp3) in:
Platforms->Android->Resources=>raw folder.
Tried build actions:
AndroidAsset
Resource
AndroidResource
`
var channelId = $"{PackageName}.general";
var notificationManager = (NotificationManager)GetSystemService(NotificationService);
var channel = new NotificationChannel(channelId, "General", NotificationImportance.Default);
var alarmAttributes = new AudioAttributes.Builder()
.SetContentType(AudioContentType.Music)
.SetUsage(AudioUsageKind.Notification).Build();
var soundNameWithoutExtension = "notify2";
var soundFilePath = $"{ContentResolver.SchemeAndroidResource}://{Android.App.Application.Context.PackageName}/raw/{soundNameWithoutExtension}";
var soundFileUri = Android.Net.Uri.Parse(soundFilePath);
I am porting over a Xamarin project (native iOS and Android).
I cannot get the Android to play the custom sound file. iOS is working fine.
I have an mp3 file (notify2.mp3) in:
Platforms->Android->Resources=>raw folder.
Tried build actions:
`
var channelId = $"{PackageName}.general";
var notificationManager = (NotificationManager)GetSystemService(NotificationService);
var channel = new NotificationChannel(channelId, "General", NotificationImportance.Default);
var alarmAttributes = new AudioAttributes.Builder()
.SetContentType(AudioContentType.Music)
.SetUsage(AudioUsageKind.Notification).Build();
var soundNameWithoutExtension = "notify2";
var soundFilePath = $"{ContentResolver.SchemeAndroidResource}://{Android.App.Application.Context.PackageName}/raw/{soundNameWithoutExtension}";
var soundFileUri = Android.Net.Uri.Parse(soundFilePath);
channel.SetSound(soundFileUri, alarmAttributes);
notificationManager.CreateNotificationChannel(channel);
FirebaseCloudMessagingImplementation.ChannelId = channelId;
`
The text was updated successfully, but these errors were encountered: