复制代码<script setup>
import {
onLoad,
onShow,
onLaunch,
onHide
} from "@dcloudio/uni-app";
// uni-id的云对象
const uniIdCo = uniCloud.importObject("uni-id-co", {
customUI: true
})
onLaunch(async () => {
if (uni.getPushClientId) {
console.log('设置pushID');
try {
let rt = await uni.getPushClientId()
let pushClientId = rt.cid
console.log(pushClientId);
let res = await uniIdCo.setPushCid({
pushClientId
})
console.log(res, '设置res');
} catch (e) {
console.log(e, '错误');
//TODO handle the exception
}
}
});
onShow(() => {
console.log("B 页面 onShow");
});
</script>
<style>
/*每个页面公共css */
</style>

- 发布:2023-06-27 01:04
- 更新:2023-06-27 19:28
- 阅读:94
【报Bug】在生命周期钩子的组合式 API onLaunch 中调用 uni.getPushClientId() 报错init am error: no api impl found
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: 10
HBuilderX类型: Alpha
HBuilderX版本号: 3.8.6
手机系统: Android
手机系统版本号: Android 12
手机厂商: 鼎桥
手机机型: TDT-MA01
页面类型: vue
vue版本: vue3
打包方式: 云端
项目创建方式: HBuilderX
示例代码:
操作步骤:
在生命周期钩子的组合式 API onLaunch 中调用 uni.getPushClientId() 就会复现bug
在生命周期钩子的组合式 API onLaunch 中调用 uni.getPushClientId() 就会复现bug
预期结果:
预期setPushCid 设置成功
预期setPushCid 设置成功
实际结果:
报错
00:59:15.194 [GtPush]
00:59:15.233 init am error: no api impl found
Error: init am error: no api impl found
at w3 (app-service.js:17548:21)
at Object._2 [as getStorage] (app-service.js:17558:15)
at Object.s3 [as getSync] (app-service.js:17832:33)
at Function.init (app-service.js:18337:42)
at Function.init (app-service.js:18291:26)
at Object.r4 [as init] (app-service.js:17460:26)
at app-service.js:23293:12
at app-service.js:23374:3
00:59:15.251 [Object] {"errMsg":"getPushClientId:fail init am error: no api impl found"} , 错误 at App.vue:23
报错
00:59:15.194 [GtPush]
00:59:15.233 init am error: no api impl found
Error: init am error: no api impl found
at w3 (app-service.js:17548:21)
at Object._2 [as getStorage] (app-service.js:17558:15)
at Object.s3 [as getSync] (app-service.js:17832:33)
at Function.init (app-service.js:18337:42)
at Function.init (app-service.js:18291:26)
at Object.r4 [as init] (app-service.js:17460:26)
at app-service.js:23293:12
at app-service.js:23374:3
00:59:15.251 [Object] {"errMsg":"getPushClientId:fail init am error: no api impl found"} , 错误 at App.vue:23
bug描述:
在生命周期钩子的组合式 API onLaunch 中调用 uni.getPushClientId()
报错
00:59:15.194 [GtPush]
00:59:15.233 init am error: no api impl found
Error: init am error: no api impl found
at w3 (app-service.js:17548:21)
at Object._2 [as getStorage] (app-service.js:17558:15)
at Object.s3 [as getSync] (app-service.js:17832:33)
at Function.init (app-service.js:18337:42)
at Function.init (app-service.js:18291:26)
at Object.r4 [as init] (app-service.js:17460:26)
at app-service.js:23293:12
at app-service.js:23374:3
00:59:15.251 [Object] {"errMsg":"getPushClientId:fail init am error: no api impl found"} , 错误 at App.vue:23
1 个回复
DCloud_uniCloud_JSON
仅启用在线推送而不启用离线推送时,调用
uni.getPushClientId
会报getPushClientId:fail init am error: no api impl found
的问题已确认,会在下一个版本的 HBuilderX 修复此问题;感谢反馈,已给你的社区账号加分。