emis-app/common/messageNotice/index.js

36 lines
1002 B
JavaScript
Raw Normal View History

2024-06-16 14:35:23 +00:00
import { setClipboardData, showToast } from "@/common/untool"
2024-12-29 10:06:51 +00:00
import { pushAddEventListenerInit } from "@/common/messageNotice/socket"
2024-06-16 14:35:23 +00:00
// #ifdef APP-PLUS
var jpushModule = uni.requireNativePlugin("JG-JPush");
var audioObj = uni.getBackgroundAudioManager();
// #endif
const getPushClientId = ()=> {
return new Promise((resolve, reject)=>{
// uni-app客户端获取push客户端标记
uni.getPushClientId({
success: (res) => {
let push_clientid = res.cid
console.log('客户端推送标识:', push_clientid)
resolve(res)
},
fail(err) {
console.log('getPushClientId err =========', err)
reject(err)
}
})
})
}
export const onPushMessage = async()=> {
2024-12-29 10:06:51 +00:00
pushAddEventListenerInit() // 监听 消息栏的点击事件
2024-06-16 14:35:23 +00:00
uni.onPushMessage((res) => {
console.log("收到推送消息 onPushMessage ===== ",res) //监听推送消息
showToast(JSON.stringify(res))
})
let cltRes = await getPushClientId()
// 复制 PushClientId
2024-06-23 08:19:00 +00:00
// setClipboardData(cltRes.cid)
2024-06-16 14:35:23 +00:00
}