Browse Source

push

devlop
mo-bai 4 years ago
parent
commit
f8e353cc63
2 changed files with 15 additions and 9 deletions
  1. 20
      App.vue
  2. 4
      utils/is.js

20
App.vue

@ -1,6 +1,6 @@
<script>
import { go2 } from '@/utils/hook.js'
import { isObject } from '@/utils/is.js'
import { isString } from '@/utils/is.js'
import store from '@/store/index.js'
import handlePushMsg from '@/utils/handlePushMsg.js'
export default {
@ -28,23 +28,25 @@ export default {
plus.push.addEventListener(
'receive',
function (msg) {
if (!isObject(msg.payload)) {
if (isString(msg.payload)) {
msg.payload = JSON.parse(msg.payload)
}
if (client === 'ios') {
if (msg.aps == null && msg.type == 'receive') {
let content = msg.payload.content
let title = msg.payload.title
let content = msg.content
let title = msg.title
let payload = JSON.stringify(msg.payload)
plus.push.createMessage(content, payload, {
title: title
title: title,
})
}
}
if (client === 'android') {
let title = msg.payload.title
let content = msg.payload.content
plus.push.createMessage(content, msg.payload, { title: title })
let title = msg.title
let content = msg.content
plus.push.createMessage(content, JSON.stringify(msg.payload), {
title: title,
})
}
},
false
@ -56,7 +58,7 @@ export default {
//
plus.runtime.setBadgeNumber(0)
},
onHide: function () {}
onHide: function () {},
}
</script>

4
utils/is.js

@ -19,3 +19,7 @@ export function isArray(val) {
export function isDate(val) {
return is(val, 'Date')
}
export function isString(val) {
return is(val, 'String')
}
Loading…
Cancel
Save