在Android 8.0(Oreo)下面的设备上,FCM推送工作正常。但是在奥利奥自定义声音完全不起作用,即使应用程序在前台,通知也没有显示到状态栏。
{
"to" : "fcm_token",
"notification" : {
"priority" : "high",
"title": "Greetings!",
"body" : "Hope you are enjoying the day.",
"sound" : "custom_sound"
}
}
FCM的配置是,
Uri soundUri = Uri.parse("android.resource://" + getApplicationContext().getPackageName() + "/" +R.raw.custom_sound);
String CHANNEL_ID = getPackageName();
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this, CHANNEL_ID)
.setSmallIcon(R.drawable.ic_logo)
.setContentTitle(title)
.setContentText(body)
.setAutoCancel(false)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setSound(soundUri);
我不知道我错过了什么。任何建议都表示赞赏。