提交 8618a160 编写于 作者: fxy060608's avatar fxy060608 提交者: qiang

feat(push): add enabled event

上级 9c60644c
......@@ -103,6 +103,10 @@ var GtPush = /*@__PURE__*/getDefaultExportFromCjs(gtpushMin);
// if (process.env.UNI_PUSH_DEBUG) {
// GtPush.setDebugMode(true)
// }
// @ts-expect-error
uni.invokePushCallback({
type: 'enabled',
});
const appid = process.env.UNI_APP_ID;
if (!appid) {
Promise.resolve().then(() => {
......
// @ts-expect-error
uni.invokePushCallback({
type: 'enabled',
});
Promise.resolve().then(() => {
plus.push.setAutoNotification && plus.push.setAutoNotification(false);
const info = plus.push.getClientInfo();
......
......@@ -8,6 +8,7 @@ import {
let cid
let cidErrMsg
let enabled
function normalizePushMessage (message) {
try {
......@@ -19,7 +20,9 @@ function normalizePushMessage (message) {
export function invokePushCallback (
args
) {
if (args.type === 'clientId') {
if (args.type === 'enabled') {
enabled = true
} else if (args.type === 'clientId') {
cid = args.cid
cidErrMsg = args.errMsg
invokeGetPushCidCallbacks(cid, args.errMsg)
......@@ -61,6 +64,12 @@ export function getPushClientId (args) {
const hasSuccess = isFn(success)
const hasFail = isFn(fail)
const hasComplete = isFn(complete)
Promise.resolve().then(() => {
if (typeof enabled === 'undefined') {
enabled = false
cid = ''
cidErrMsg = 'unipush is not enabled'
}
getPushCidCallbacks.push((cid, errMsg) => {
let res
if (cid) {
......@@ -78,8 +87,9 @@ export function getPushClientId (args) {
hasComplete && complete(res)
})
if (typeof cid !== 'undefined') {
Promise.resolve().then(() => invokeGetPushCidCallbacks(cid, cidErrMsg))
invokeGetPushCidCallbacks(cid, cidErrMsg)
}
})
}
const onPushMessageCallbacks = []
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册