我初始化成功后 获取registrationID 获取不到 我写在 app.vue onShow() 里
// 初始化推送
await this.$store.dispatch('jPush/initJyJPush')
initJyJPush({
commit,
dispatch
}) {
const systemInfo = uni.getSystemInfoSync()
return new Promise((resolve, reject) => {
if (systemInfo.platform === 'android') {
jyJPush.android_init(res => {
dispatch('JyPushRegistrationID', {
root: true
})
resolve(res)
})
} else {
reject()
}
})
},
JyPushRegistrationID({
commit
}) {
return new Promise((resolve, reject) => {
jyJPush.getRegistrationID(
result => {
if (result) {
console.log(JSON.stringify(result))
commit('SET_REGISTRATIONID', result.registrationID)
resolve(result.registrationID)
} else {
reject(result)
}
});
})
},
1 个回复
JiYis - JiYis
初始化后不能马上获取regid,方法都是异步的