uni-app 【报Bug】plus.push.getClientInfo()获取不到cid,配置已按文档核对多遍
uni-app 【报Bug】plus.push.getClientInfo()获取不到cid,配置已按文档核对多遍
开发环境 | 版本号 | 项目创建方式 |
---|---|---|
Mac | 14.4.1 (23E224) | HBuilderX |
产品分类:uniapp/App
PC开发环境操作系统:Mac
HBuilderX类型:正式
HBuilderX版本号:4.14
手机系统:iOS
手机系统版本号:iOS 16
手机厂商:苹果
手机机型:iphone14 pro max
页面类型:vue
vue版本:vue2
打包方式:离线
操作步骤:
- 每次执行都会显示clientid为空的字符串
预期结果:
- clientid应该有数据不应该为空的字符串
实际结果:
- 每次执行该代码都打印clientid为空的字符串
bug描述:
let clientInfo = uni.getStorageSync("clientInfo") || plus.push.getClientInfo()
console.log('-----onBindAliasOfGetui----uni.getStorageSync("clientInfo")-----', clientInfo)
得到的结果如图
更多关于uni-app 【报Bug】plus.push.getClientInfo()获取不到cid,配置已按文档核对多遍的实战教程也可以访问 https://www.itying.com/category-93-b0.html
离线打包,可以参考这个解决 https://ask.dcloud.net.cn/question/184711
更多关于uni-app 【报Bug】plus.push.getClientInfo()获取不到cid,配置已按文档核对多遍的实战教程也可以访问 https://www.itying.com/category-93-b0.html
参照了。里面的配置都对过了 还是不行
在 uni-app
中使用 plus.push.getClientInfo()
获取不到 cid
的问题,可能是由于以下几个原因导致的。你可以按照以下步骤进行排查和解决:
1. 确认配置是否正确
确保你已经按照文档正确配置了推送相关的内容,包括:
- App 模块配置:在
manifest.json
中正确配置了推送模块(如Push
模块)。 - 推送服务配置:确保你已经正确配置了推送服务(如极光推送、个推等)的
AppKey
和AppSecret
等信息。 - 权限配置:确保在
manifest.json
中正确配置了推送所需的权限(如网络权限、通知权限等)。
2. 检查设备网络状态
确保设备网络连接正常,推送服务需要网络连接才能获取到 cid
。
3. 确认推送服务是否正常
- 服务端配置:确保推送服务端配置正确,并且服务端能够正常生成
cid
。 - 客户端日志:查看客户端日志,确认是否有相关错误信息。
4. 检查代码逻辑
确保你在正确的时机调用 plus.push.getClientInfo()
,并且处理了可能的异步操作。例如:
document.addEventListener('plusready', function() {
plus.push.getClientInfo(function(info) {
console.log('Client Info:', info);
if (info && info.clientid) {
console.log('CID:', info.clientid);
} else {
console.error('Failed to get CID');
}
}, function(error) {
console.error('Error getting client info:', error);
});
});