2***@qq.com
2***@qq.com
  • 发布:2024-10-25 14:16
  • 更新:2024-10-25 14:16
  • 阅读:42

android 设定通知组 设定自定义音频

分类:uni-app

目前震动和提醒说正常的 但是拿不到音频文件地址打印出开是空的 这个代码在原生上面是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", "通知渠道已创建")  
    }  
}
2024-10-25 14:16 负责人:无 分享
已邀请:

要回复问题请先登录注册