ERROR] Method[getPushManager] was not found in index.obj.js in uni-app

ERROR] Method[getPushManager] was not found in index.obj.js in uni-app

开发环境 版本号 项目创建方式
Windows 10 HBuilderX

产品分类:uniapp/App

PC开发环境操作系统:Windows

HBuilderX类型:正式

HBuilderX版本号:4.76

手机系统:iOS

手机系统版本号:iOS 12.3

手机厂商:苹果

手机机型:13pro

页面类型:vue

vue版本:vue2

打包方式:云端

项目创建方式:HBuilderX


示例代码:

// 开发文档: https://uniapp.dcloud.net.cn/uniCloud/cloud-obj function uniPush(appId) { return uniCloud.getPushManager({appId}) } const uniID = require(‘uni-id-common’) module.exports = { _before: async function() { const clientInfo = this.getClientInfo() this.uniID = uniID.createInstance({ clientInfo }) const token = this.getUniIdToken() let payload = await this.uniID.checkToken(token) let role = payload.role||[] //检查是不是管理员,或者自己的云函数调用此云函数 if(clientInfo.source != ‘server’ && !role.includes(‘admin’)){ return { errCode: ‘uni-push-co-permission-denied’, errMsg: ‘你没有访问此接口权限’ } } }, async sendMessage(data) { const appId = data.appId data.must_report = true //默认为false,消息接受者为单设备时,不统计推送结果。开启此项将都会统计。但整体推送速度会慢100-500毫秒 // delete data.appId let res = await uniPush(appId).sendMessage(data) if (res.errCode == 0 && res.before_id) { const UniPushCo = uniCloud.importObject(“uni-push-co”) data.before_id = res.before_id //查询的初始id,用于高性能分页查询 data.taskid = res.data.taskid || Object.keys(res.data)[0] UniPushCo.sendMessage(data).catch(e=>{ // console.log(e.message); })
// 等待500毫秒给下一个请求发出去的时间
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve(res)
}, 500)
})
}
return res
}, async getReport({
appId,
taskid
}) {
let res = await uniPush(appId).getReport({
taskid
})
//获取推送结果
console.log(JSON.stringify(res));
return res
},
async getAdminUrl(appId) {
let res = await uniPush(appId).getAdminUrl() //获取推送结果
console.log(JSON.stringify(res));
return res
}
}


更多关于ERROR] Method[getPushManager] was not found in index.obj.js in uni-app的实战教程也可以访问 https://www.itying.com/category-93-b0.html

2 回复

是不是没关联push公共模块?

更多关于ERROR] Method[getPushManager] was not found in index.obj.js in uni-app的实战教程也可以访问 https://www.itying.com/category-93-b0.html


有两个模块 能关联的都关联了

回到顶部