提交 5b9c619f 编写于 作者: fxy060608's avatar fxy060608

feat(push): plus.push.setAutoNotification

上级 4559fff3
Promise.resolve().then(() => { Promise.resolve().then(() => {
plus.push.setAutoNotification && plus.push.setAutoNotification(false);
const info = plus.push.getClientInfo(); const info = plus.push.getClientInfo();
if (info.clientid) { if (info.clientid) {
// @ts-expect-error // @ts-expect-error
......
...@@ -9,24 +9,9 @@ import { ...@@ -9,24 +9,9 @@ import {
let cid let cid
let cidErrMsg let cidErrMsg
function normalizePushMessage (type, message) { function normalizePushMessage (message) {
try { try {
const res = JSON.parse(message) return JSON.parse(message)
if (type === 'receive') {
if (res.payload) {
if (res.aps) {
res.payload.aps = res.aps
}
return res.payload
}
} else if (type === 'click') {
delete res.type
delete res.__UUID__
delete res.appid
if (res.aps && res.aps.alert) {
res.title = res.aps.alert.title
}
}
} catch (e) {} } catch (e) {}
return message return message
} }
...@@ -42,14 +27,14 @@ export function invokePushCallback ( ...@@ -42,14 +27,14 @@ export function invokePushCallback (
onPushMessageCallbacks.forEach((callback) => { onPushMessageCallbacks.forEach((callback) => {
callback({ callback({
type: 'receive', type: 'receive',
data: normalizePushMessage('receive', args.message) data: normalizePushMessage(args.message)
}) })
}) })
} else if (args.type === 'click') { } else if (args.type === 'click') {
onPushMessageCallbacks.forEach((callback) => { onPushMessageCallbacks.forEach((callback) => {
callback({ callback({
type: 'click', type: 'click',
data: normalizePushMessage('click', args.message) data: normalizePushMessage(args.message)
}) })
}) })
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册