目前震动和提醒说正常的 但是拿不到音频文件地址打印出开是空的 这个代码在原生上面是ok的 我也重新打了自定义基座
// 写入通知组
export const writenotificationsgroup = () => {
const context = UTSAndroid.getAppContext() as Context
const notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
// 创建通知渠道,适用于 Android 8.0+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
const audioAttributes = new AudioAttributes.Builder()
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
.setUsage(AudioAttributes.USAGE_NOTIFICATION)
.build();
const mUri : Uri = Uri.parse("android.resource://" + context.getPackageName() + "/" + R.raw.sund);
console.log(mUri);
const channelId = "Clcok_Service"
const channelName = "闹钟提醒"
let channel = new NotificationChannel(channelId, channelName, NotificationManager.IMPORTANCE_HIGH);
channel.enableVibration(true);
channel.enableLights(true);
channel.lightColor = Color.BLUE
channel.setDescription("用于无网络下的闹钟提醒")
// channel.setSound(mUri, audioAttributes);
notificationManager.createNotificationChannel(channel)
Log.d("Notification", "通知渠道已创建")
}
}
0 个回复