【发布时间】:2022-07-12 22:07:00
【问题描述】:
请注意,我们正在尝试向用户的 Android 设备发送带有自定义声音的推送通知。从我们的应用程序使用 FCM 发送推送通知时,消息确实到达了用户的设备,但负载中设置的自定义声音不会播放。通知到达,但自定义声音不播放,默认通知声音也不播放。 这是我们正在使用的有效负载
$notification = [
'title' =>"Hello",
'body' =>"Hello",
'image'=>''
'sound'=>'https://mbracecloud.com/sound.mp3'
];
Firebase.java:NotificationCompat.Builder
Uri soundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, MainActivity.asw_fcm_channel)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle(title)
.setContentText(message)
.setAutoCancel(true)
.setSound(soundUri)
.setContentIntent(pendingIntent);
Notification noti = notificationBuilder.build();
noti.flags = Notification.DEFAULT_LIGHTS | Notification.FLAG_AUTO_CANCEL;
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(notification_id, notificationBuilder.build());
请指导我们哪里出错。
【问题讨论】:
标签: android push-notification notifications firebase-cloud-messaging