提交 27533bda 编写于 作者: fxy060608's avatar fxy060608

fix(push): remove setAutoNotification

上级 9ff66caf
......@@ -168,7 +168,9 @@ module.exports = {
: 'import \'@dcloudio/uni-stat/dist/uni-stat.es.js\';'
},
getPlatformPush () {
if (process.env.UNI_PUSH_V2_OFFLINE || process.env.UNI_PUSH_V1) {
if (process.env.UNI_PUSH_V1) {
return ';import \'@dcloudio/vue-cli-plugin-uni/packages/uni-push/dist/uni-push-v1.plus.es.js\';'
} else if (process.env.UNI_PUSH_V2_OFFLINE) {
return ';import \'@dcloudio/vue-cli-plugin-uni/packages/uni-push/dist/uni-push.plus.es.js\';'
} else if (process.env.UNI_PUSH_V2) {
return ';import \'@dcloudio/vue-cli-plugin-uni/packages/uni-push/dist/uni-push.es.js\';'
......
function initPushNotification() {
// 仅 App 端
if (typeof plus !== 'undefined' && plus.push) {
plus.globalEvent.addEventListener('newPath', ({ path }) => {
if (!path) {
return;
}
// 指定的页面为当前页面
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
if (currentPage &&
currentPage.$page &&
currentPage.$page.fullPath === path) {
return;
}
// 简单起见,先尝试 navigateTo 跳转,失败后,再尝试 tabBar 跳转
uni.navigateTo({
url: path,
fail(res) {
if (res.errMsg.indexOf('tabbar') > -1) {
uni.switchTab({
url: path,
fail(res) {
console.error(res.errMsg);
},
});
}
else {
console.error(res.errMsg);
}
},
});
});
}
}
// @ts-expect-error
uni.invokePushCallback({
type: 'enabled',
offline: true,
});
Promise.resolve().then(() => {
initPushNotification();
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册