uu
This commit is contained in:
parent
ad8d679b24
commit
034facfbf0
4
App.vue
4
App.vue
@ -8,6 +8,7 @@
|
|||||||
// import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update';
|
// import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update';
|
||||||
import { USERKEY, COMMONKEY } from "@/store/actionKey"
|
import { USERKEY, COMMONKEY } from "@/store/actionKey"
|
||||||
import { checkUpdate } from "@/common/appUpdate"
|
import { checkUpdate } from "@/common/appUpdate"
|
||||||
|
import { onPushMessage } from "@/common/messageNotice"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
globalData: {
|
globalData: {
|
||||||
@ -16,7 +17,8 @@
|
|||||||
onLaunch: function() {
|
onLaunch: function() {
|
||||||
this.$store.dispatch(USERKEY.GETUSERINFO)
|
this.$store.dispatch(USERKEY.GETUSERINFO)
|
||||||
this.$store.dispatch(COMMONKEY.GETDIC)
|
this.$store.dispatch(COMMONKEY.GETDIC)
|
||||||
|
// 监听消息通知
|
||||||
|
onPushMessage()
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
console.log(
|
console.log(
|
||||||
`%c hello uniapp %c v${version} `,
|
`%c hello uniapp %c v${version} `,
|
||||||
|
|||||||
34
common/messageNotice/index.js
Normal file
34
common/messageNotice/index.js
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import { setClipboardData, showToast } from "@/common/untool"
|
||||||
|
|
||||||
|
// #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()=> {
|
||||||
|
uni.onPushMessage((res) => {
|
||||||
|
console.log("收到推送消息 onPushMessage ===== ",res) //监听推送消息
|
||||||
|
showToast(JSON.stringify(res))
|
||||||
|
})
|
||||||
|
let cltRes = await getPushClientId()
|
||||||
|
// 复制 PushClientId
|
||||||
|
setClipboardData(cltRes.cid)
|
||||||
|
}
|
||||||
@ -95,6 +95,12 @@
|
|||||||
"appkey_ios" : "aatodo",
|
"appkey_ios" : "aatodo",
|
||||||
"appkey_android" : "b7feefb9882f1d0953fbeffb1cef8aec"
|
"appkey_android" : "b7feefb9882f1d0953fbeffb1cef8aec"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"push" : {
|
||||||
|
"unipush" : {
|
||||||
|
"version" : "2",
|
||||||
|
"offline" : true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"orientation" : [ "portrait-primary" ],
|
"orientation" : [ "portrait-primary" ],
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user