onLaunch: function(options) {
// 推送相关
// #ifdef APP-PLUS
setTimeout(() => {
this.getCid()
}, 1000)
// #endif
},
methods: {
getCid() {
let pinf = plus.push.getClientInfo();
let cid = pinf && pinf.clientid || '';
if (!cid) {
plus.push.getClientInfoAsync((info) => {
cid = info["clientid"];
if (cid) {
uni.setStorageSync('cid', cid)
} else {
this.globalData.getCidCount++
this.globalData.getCidCount < 10 ? setTimeout(() => {
this.getCid()
}, 100) : ""
}
console.log("cid", cid)
}, err => {
uni.showModal({
title: "cidError",
content: JSON.stringify(err)
})
});
} else {
console.log("同步获取")
uni.showModal({
title: "同步获取cid",
content: cid
})
}
},
}
在App.vue里执行上面的代码,安卓和部分苹果手机能获取到clientid,但是有些苹果手机不管同步获取还是异步获取都拿不到clientid,异步获取时回调函数都不执行,不管是正确的回调还是错误的回调
深 (作者)
用定时器延迟获取也不行吗?
2023-05-03 17:44
DCloud_iOS_WZT
回复 深: 不行
2023-05-05 11:23