HarmonyOS 关于notificationManager.publish
通过notificationManager.publish发送通知,状态栏不会像其他系统那样弹出通知内容,也没有显示应用通知图标,只有当状态栏下拉以后,能看到通知。
notificationManager.publish代码如下
// 发起通知
let request: notificationManager.NotificationRequest = {
id: 1,
content: {
notificationContentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: '注意!手机银行已经切换到后台',
text: '手机银行已切换到后台',
additionalText: '点击重新进入手机银行'
},
},
isFloatingIcon:true,
notificationSlotType:notificationManager.SlotType.SERVICE_INFORMATION,
}
notificationManager.publish(request, (err) => {
if (null != err) {
Logger.error(`EntryAbility => onBackground 发送通知异常:${JSON.stringify(err)}`)
return
}
Logger.debug(`通知发送成功`)
})
HarmonyOS
赞
收藏 0
回答 1
待解决
相关问题
调用notificationManager.publish发布通知失败
2774浏览 • 1回复 待解决
HarmonyOS notificationManager问题
1166浏览 • 1回复 待解决
HarmonyOS ohpm publish如何加上组织名字
1074浏览 • 1回复 待解决
HarmonyOS notificationManager中actionButtons的使用问题
722浏览 • 1回复 待解决
ohpm publish如何指定秘钥库密码ohpm publish如何指定秘钥库密码
1406浏览 • 1回复 待解决
HarmonyOS HAR publish时需要的密码问题
1825浏览 • 1回复 待解决
调用请求通知notificationManager.requestEnableNotification接口,报错17700001
3452浏览 • 1回复 待解决
ohpm publish 组问题,该如何解决?
1445浏览 • 1回复 待解决
ohpm publish 推送har包大小的限制
1708浏览 • 1回复 待解决
HarmonyOS 执行ohpm publish 时,解决需要手动输入 passphrase的问题?
1412浏览 • 1回复 待解决
HarmonyOS notificationManager普通文本通知点击事件,和点击通知后自动消失
936浏览 • 1回复 待解决
HarmonyOS 使用用户通知服务notificationManager,管理通知渠道配置后未生效
996浏览 • 1回复 待解决
HarmonyOS 关于Socket
962浏览 • 1回复 待解决
HarmonyOS 关于手势问题
1013浏览 • 1回复 待解决
HarmonyOS 关于openCustomDialog方法
912浏览 • 1回复 待解决
HarmonyOS 关于屏幕高度
1012浏览 • 1回复 待解决
HarmonyOS 关于crash问题
1820浏览 • 1回复 待解决
HarmonyOS关于navigation问题
2078浏览 • 1回复 待解决
HarmonyOS 关于屏幕高度?
1012浏览 • 0回复 待解决
关于HarmonyOS Promise机制
1843浏览 • 1回复 待解决
HarmonyOS 关于$$.this的写法
907浏览 • 1回复 待解决
HarmonyOS 关于状态管理
1407浏览 • 1回复 待解决





















将notificationSlotType改成notificationManager.SlotType.SOCIAL_COMMUNICATION,因为只有SOCIAL_COMMUNICATION类型支持横幅通知,相关规则可参考:
https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/notification-slot-V5
另外测试时,注意手机设置里,应用的通知管理中,需要把提醒方式的“横幅通知”勾上,这样才会直接弹出消息。