【发布时间】:2021-02-10 22:39:35
【问题描述】:
我已经使用 Firebase 为推送开发了适用于 Android 的应用程序,我想使用设备的默认声音发送推送通知。我已经在 android 6 上测试了应用程序并且工作正常,它显示了图标、标题、正文并有声音。但是当我将推送发送到 android 9 设备时,它收到了推送但没有声音、振动、led....只有标题和正文。能告诉我如何在 Android 9 的频道上设置所有的光、振动和声音标志吗?我检查了手机设置,我可以看到默认情况下应用程序是如何被禁用的,而频道是如何只启用声音的,我想像其他应用程序一样默认启用它 谢谢
代码部分。
var channelId = channel.NotificationChannelId;
var channelName = channel.NotificationChannelName;
var channelImportance = channel.NotificationChannelImportance;
var notificationManager = (NotificationManager)context.GetSystemService(Context.NotificationService);
var notChannel = new NotificationChannel(channelId, channelName, channelImportance);
if (SoundUri != null)
{
try
{
var soundAttributes = new AudioAttributes.Builder()
.SetContentType(AudioContentType.Sonification)
.SetUsage(AudioUsageKind.Notification).Build();
notChannel.SetSound(SoundUri, soundAttributes);
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex);
}
}
notificationManager.CreateNotificationChannel(notChannel);
【问题讨论】:
-
能否请您出示您正在使用的代码?
-
我已经添加了我使用的代码片段
标签: android firebase xamarin push-notification