- 发布:2024-12-09 13:57
- 更新:2024-12-10 08:11
- 阅读:93
【报Bug】Uniapp 在线onPushMessage监听不到通知信息 版本:4.36
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: win11
HBuilderX类型: 正式
HBuilderX版本号: 4.36
手机系统: 全部
页面类型: vue
vue版本: vue2
打包方式: 云端
项目创建方式: HBuilderX
测试过的手机:
示例代码:
//客户端代码:
uni.onPushMessage(res => {
console.log('收到推送消息:', res); //监听推送消息
var payload = res.data.payload;
});
//服务端代码:
exports.main = async (event, context) => {
let request = JSON.parse(event.body);
let functionType = request.functionType;
//发送推送消息
if (functionType == "sendMessage") {
return await uniPush.sendMessage({
"push_clientid": request.push_clientid, //推送用户标识
"title": request.title,
"content": request.content,
"payload": request.payload, //透传信息
"sound": "pushsound",
"force_notification": true, //无论是离线推送还是在线推送,都自创建通知栏消息
"badge": "+1", //设置应用右上角数字
"request_id": request.request_id,
"content_available": request.available, //0表示普通通知消息(默认为0); 1表示静默推送(无通知栏消息),静默推送时不需要填写其他参数。
"channel": {
"HW": "NORMAL",
"XM": "104519",
"OP": "fl_system",
"VV": 1
},
// "category": {
// "huawei": "VOIP",
// "vivo": "IM"
// },
"settings": {
"ttl": -1,
},
"options": {
"IOS": {
"type": "notify",
"aps": {
"content-available": 0
},
"auto_badge": "+1",
},
"HW": {
"/message/android/notification/default_sound": false,
"/message/android/notification/badge/add_num": 1,
"/message/android/notification/badge/set_num": 1,
"/message/android/notification/importance": "NORMAL",
"/message/android/notification/channel_id": "yk_wrls",
"/message/android/category": "VOIP"
},
"XM": {
"/extra.channel_id": "104519",
"/extra.locale": "zh_CN"
},
"OP": {
"/channel_id": "fl_system"
},
"VV": {
"/classification": 1
},
"UPS": {
"bigText": request.title
}
}
})
}
}
//客户端代码:
uni.onPushMessage(res => {
console.log('收到推送消息:', res); //监听推送消息
var payload = res.data.payload;
});
//服务端代码:
exports.main = async (event, context) => {
let request = JSON.parse(event.body);
let functionType = request.functionType;
//发送推送消息
if (functionType == "sendMessage") {
return await uniPush.sendMessage({
"push_clientid": request.push_clientid, //推送用户标识
"title": request.title,
"content": request.content,
"payload": request.payload, //透传信息
"sound": "pushsound",
"force_notification": true, //无论是离线推送还是在线推送,都自创建通知栏消息
"badge": "+1", //设置应用右上角数字
"request_id": request.request_id,
"content_available": request.available, //0表示普通通知消息(默认为0); 1表示静默推送(无通知栏消息),静默推送时不需要填写其他参数。
"channel": {
"HW": "NORMAL",
"XM": "104519",
"OP": "fl_system",
"VV": 1
},
// "category": {
// "huawei": "VOIP",
// "vivo": "IM"
// },
"settings": {
"ttl": -1,
},
"options": {
"IOS": {
"type": "notify",
"aps": {
"content-available": 0
},
"auto_badge": "+1",
},
"HW": {
"/message/android/notification/default_sound": false,
"/message/android/notification/badge/add_num": 1,
"/message/android/notification/badge/set_num": 1,
"/message/android/notification/importance": "NORMAL",
"/message/android/notification/channel_id": "yk_wrls",
"/message/android/category": "VOIP"
},
"XM": {
"/extra.channel_id": "104519",
"/extra.locale": "zh_CN"
},
"OP": {
"/channel_id": "fl_system"
},
"VV": {
"/classification": 1
},
"UPS": {
"bigText": request.title
}
}
})
}
}
操作步骤:
直接调用或通过代码逻辑调用发送通知接口,手机通知栏创建了通知信息,但是不进方法
直接调用或通过代码逻辑调用发送通知接口,手机通知栏创建了通知信息,但是不进方法
预期结果:
手机创建通知栏信息,监听方法监听到信息
手机创建通知栏信息,监听方法监听到信息
实际结果:
手机创建通知栏信息,监听方法监听不到信息,目前线上所有手机都监听不到通知信息
手机创建通知栏信息,监听方法监听不到信息,目前线上所有手机都监听不到通知信息
bug描述:
Uniapp 在线onPushMessage监听不到通知信息
2 个回复
5***@yingkelawyer.com (作者)
关闭
套马杆的套子 - 没有解决不了的问题,只有解决不完的问题
force_notification去掉试试呢