getCid() {
let info = plus.push.getClientInfo()
console.log('push info=============', info)
if(info && info["clientid"]) {
let cid = info["clientid"]
console.log('get cid=================', cid)
uni.showToast({
title: 'cid: ' + cid,
icon: 'none'
})
if (cid && cid.length > 0) {
bindPushCid({
equipment_id: cid,
equipment_type: plus.os.name.toLowerCase()
}).then(res => {
if (res.status_code === 200) {
uni.showToast({
title:'推送绑定成功',
icon:'none'
})
}else{
uni.showToast({
title: res.detail || '加载失败',
icon: 'none'
})
}
}).catch((err) => {
uni.showToast({
title: err || '绑定失败',
icon: 'none'
})
})
}
}
},
![f***@sina.cn](https://img-cdn-tc.dcloud.net.cn/account/identicon/5284887fd6f680a65c7c466f9891feae.png)
- 发布:2024-09-30 08:19
- 更新:2024-12-16 18:18
- 阅读:148
产品分类: uniapp/App
PC开发环境操作系统: Mac
PC开发环境操作系统版本号: 14.3.1 (23D60)
HBuilderX类型: 正式
HBuilderX版本号: 4.23
手机系统: iOS
手机系统版本号: iOS 13.0
手机厂商: 苹果
手机机型: iPhone10
页面类型: vue
vue版本: vue2
打包方式: 离线
项目创建方式: HBuilderX
示例代码:
操作步骤:
getCid() {
let info = plus.push.getClientInfo()
console.log('push info=============', info)
if(info && info["clientid"]) {
let cid = info["clientid"]
console.log('get cid=================', cid)
uni.showToast({
title: 'cid: ' + cid,
icon: 'none'
})
if (cid && cid.length > 0) {
bindPushCid({
equipment_id: cid,
equipment_type: plus.os.name.toLowerCase()
}).then(res => {
if (res.status_code === 200) {
uni.showToast({
title:'推送绑定成功',
icon:'none'
})
}else{
uni.showToast({
title: res.detail || '加载失败',
icon: 'none'
})
}
}).catch((err) => {
uni.showToast({
title: err || '绑定失败',
icon: 'none'
})
})
}
}
},
getCid() {
let info = plus.push.getClientInfo()
console.log('push info=============', info)
if(info && info["clientid"]) {
let cid = info["clientid"]
console.log('get cid=================', cid)
uni.showToast({
title: 'cid: ' + cid,
icon: 'none'
})
if (cid && cid.length > 0) {
bindPushCid({
equipment_id: cid,
equipment_type: plus.os.name.toLowerCase()
}).then(res => {
if (res.status_code === 200) {
uni.showToast({
title:'推送绑定成功',
icon:'none'
})
}else{
uni.showToast({
title: res.detail || '加载失败',
icon: 'none'
})
}
}).catch((err) => {
uni.showToast({
title: err || '绑定失败',
icon: 'none'
})
})
}
}
},
预期结果:
hbuilder上可以正常打印
hbuilder上可以正常打印
实际结果:
xcode上打印出来没有cid
xcode上打印出来没有cid
bug描述:
集成推送unipush1.0,云端打包可以通过let info = plus.push.getClientInfo()正常获取cid,由于涉及到了原生插件,只能通过离线打包生成ipa文件,在xcode上运行项目时候,未能正常获取cid,这里遇到了2个问题。
- 通过hbuilder直接运行时候 获取到的info对应的appid 不是后台配置的推送应用appid
- hbuilder上可以正常打印info,有对应cid值,xcode上没有cid这个字段
![](http://img-cdn-tc.dcloud.net.cn/uploads/questions/20240930/40b3020f6de6b1eed80a9e29e9137035.png)
![](http://img-cdn-tc.dcloud.net.cn/uploads/questions/20240930/cd01d9610f22f9ab066156e002352094.png)
![](http://img-cdn-tc.dcloud.net.cn/uploads/questions/20240930/b70ef167a5a84da21bc130515a0d2ae3.png)
![](http://img-cdn-tc.dcloud.net.cn/uploads/questions/20240930/d6998c78d94a3eea585f6b158f75c8c1.png)