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
1天前
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
zbw_apple

https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-inner-notification-notificationrequest-V5#notificationrequest-1

sound字段 应用通知自定义铃声,需要通过Push云侧获取自定义发送铃声权限后,该字段才会生效

分享
微博
QQ
微信
回复
1天前
相关问题
HarmonyOS 自定义通知栏点击更新需求
130浏览 • 1回复 待解决
HarmonyOS 怎么自定义装饰器
168浏览 • 1回复 待解决
HarmonyOS 怎么自定义Tab的Tabbar
161浏览 • 1回复 待解决
HarmonyOS 自定义绘制接口怎么使用
35浏览 • 1回复 待解决
自定义弹窗自定义转场动画
1291浏览 • 1回复 待解决
HarmonyOS 自定义View怎么转换为PixelMap
133浏览 • 1回复 待解决
自定义资源文件怎么读取?
2525浏览 • 1回复 待解决
编译构建怎么编写自定义任务?
843浏览 • 1回复 待解决
JAVA卡片怎么自定义组件?
6762浏览 • 1回复 待解决
HarmonyOS 定义自定义组件
211浏览 • 1回复 待解决