HarmonyOS Notification怎么自定义通知声音?
//自定义声音不好使
static async publish() {
await notificationManager.addSlot(notificationManager.SlotType.SOCIAL_COMMUNICATION)
let notificationSlot: notificationManager.NotificationSlot =
await notificationManager.getSlot(notificationManager.SlotType.SOCIAL_COMMUNICATION)
let soundPath = 'file://com.example.helloapplication/data/storage/el2/base/haps/entry/files/im_message_sound.mp3'
notificationSlot.sound = soundPath
//默认sound file://system/etc/Light.ogg
// 通知Request对象
let notificationRequest: notificationManager.NotificationRequest = {
id: 1,
notificationSlotType: notificationManager.SlotType.SOCIAL_COMMUNICATION,
content: {
notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title",
text: "test_text",
additionalText: "test_additionalText"
}
}
};
notificationManager.publish(notificationRequest).then(() => {
console.info("publish success");
}).catch((err: object) => {
console.error(`publish fail: ${JSON.stringify(err)}`);
});
}
HarmonyOS
赞
收藏 0
回答 1
待解决
相关问题
HarmonyOS 自定义通知栏点击更新需求
947浏览 • 1回复 待解决
HarmonyOS 自定义弹窗怎么设置自定义动画?
1613浏览 • 1回复 待解决
Notification Kit(用户通知服务)请求通知授权
4888浏览 • 1回复 待解决
HarmonyOS notification,点击通知栏,怎么跳转到指定界面
959浏览 • 1回复 待解决
HarmonyOS 怎么自定义装饰器
1087浏览 • 1回复 待解决
【通知自定义铃声权益申请】权益开通后,PushKit远程推送依旧无法进行铃声的自定义是怎么回事?
579浏览 • 0回复 待解决
HarmonyOS 自定义工具类中怎么弹出CustomDialogController自定义弹框?
1817浏览 • 1回复 待解决
HarmonyOS 怎么自定义Tab的Tabbar
1027浏览 • 1回复 待解决
HarmonyOS 自定义绘制接口怎么使用
924浏览 • 1回复 待解决
自定义Dialog,怎么给自定义Dialog设置其他背景色
2026浏览 • 1回复 待解决
怎么实现自定义弹窗1打开自定义弹窗2
4141浏览 • 1回复 待解决
HarmonyOS 怎么设置自定义字体并获取自定义字体的宽度,高度
1145浏览 • 1回复 待解决
HarmonyOS 自定义View怎么转换为PixelMap
872浏览 • 1回复 待解决
HarmonyOS treeview怎么实现自定义Cell内容
944浏览 • 1回复 待解决
自定义弹窗自定义转场动画
2413浏览 • 1回复 待解决
JAVA卡片怎么用自定义组件?
7909浏览 • 1回复 待解决
编译构建怎么编写自定义任务?
1732浏览 • 1回复 待解决
HarmonyOS 文本怎么自定义识别高亮显示和自定义点击事件显示菜单/气泡?
1494浏览 • 1回复 待解决
HarmonyOS 自定义Popup arrow颜色怎么设置
884浏览 • 1回复 待解决
HarmonyOS button文字怎么自定义设置位置
1154浏览 • 1回复 待解决
HarmonyOS 自定义UI组件如何自定义属性方法
2162浏览 • 1回复 待解决
自定义资源文件怎么读取?
3496浏览 • 1回复 待解决
HarmonyOS 定义自定义组件
1461浏览 • 1回复 待解决
HarmonyOS CustomDialogController自定义弹窗怎么屏蔽系统返回
1382浏览 • 1回复 待解决
HarmonyOS 自定义弹窗侧滑事件怎么监听
1326浏览 • 1回复 待解决
https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-inner-notification-notificationrequest-V5#notificationrequest-1
sound字段 应用通知自定义铃声,需要通过Push云侧获取自定义发送铃声权限后,该字段才会生效