@dcloudio/uni-push 3.0.0-alpha-3050420220804008 → 3.0.0-alpha-3060020220830001
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/uni-push.es.js +42 -14
- package/dist/uni-push.plus.es.js +37 -14
- package/package.json +2 -2
- package/lib/.DS_Store +0 -0
package/dist/uni-push.es.js
CHANGED
@@ -103,21 +103,35 @@ var GtPush = /*@__PURE__*/getDefaultExportFromCjs(gtpushMin);
|
|
103
103
|
function initPushNotification() {
|
104
104
|
// 仅 App 端
|
105
105
|
if (typeof plus !== 'undefined' && plus.push) {
|
106
|
-
plus.
|
107
|
-
|
108
|
-
|
109
|
-
type: 'click',
|
110
|
-
message: result,
|
111
|
-
});
|
112
|
-
});
|
113
|
-
uni.onPushMessage((res) => {
|
114
|
-
if (res.type === 'receive' &&
|
115
|
-
res.data &&
|
116
|
-
res.data.force_notification) {
|
117
|
-
// 创建通知栏
|
118
|
-
uni.createPushMessage(res.data);
|
119
|
-
res.stopped = true;
|
106
|
+
plus.globalEvent.addEventListener('newPath', ({ path }) => {
|
107
|
+
if (!path) {
|
108
|
+
return;
|
120
109
|
}
|
110
|
+
// 指定的页面为当前页面
|
111
|
+
const pages = getCurrentPages();
|
112
|
+
const currentPage = pages[pages.length - 1];
|
113
|
+
if (currentPage &&
|
114
|
+
currentPage.$page &&
|
115
|
+
currentPage.$page.fullPath === path) {
|
116
|
+
return;
|
117
|
+
}
|
118
|
+
// 简单起见,先尝试 navigateTo 跳转,失败后,再尝试 tabBar 跳转
|
119
|
+
uni.navigateTo({
|
120
|
+
url: path,
|
121
|
+
fail(res) {
|
122
|
+
if (res.errMsg.indexOf('tabbar') > -1) {
|
123
|
+
uni.switchTab({
|
124
|
+
url: path,
|
125
|
+
fail(res) {
|
126
|
+
console.error(res.errMsg);
|
127
|
+
},
|
128
|
+
});
|
129
|
+
}
|
130
|
+
else {
|
131
|
+
console.error(res.errMsg);
|
132
|
+
}
|
133
|
+
},
|
134
|
+
});
|
121
135
|
});
|
122
136
|
}
|
123
137
|
}
|
@@ -141,7 +155,9 @@ if (!appid) {
|
|
141
155
|
});
|
142
156
|
}
|
143
157
|
else {
|
158
|
+
// #ifdef APP
|
144
159
|
initPushNotification();
|
160
|
+
// #endif
|
145
161
|
GtPush.init({
|
146
162
|
appid,
|
147
163
|
onError: (res) => {
|
@@ -175,4 +191,16 @@ else {
|
|
175
191
|
});
|
176
192
|
},
|
177
193
|
});
|
194
|
+
// 仅在 jssdk 中监听
|
195
|
+
// #ifdef APP
|
196
|
+
uni.onPushMessage((res) => {
|
197
|
+
if (res.type === 'receive' &&
|
198
|
+
res.data &&
|
199
|
+
res.data.force_notification) {
|
200
|
+
// 创建通知栏
|
201
|
+
uni.createPushMessage(res.data);
|
202
|
+
res.stopped = true;
|
203
|
+
}
|
204
|
+
});
|
205
|
+
// #endif
|
178
206
|
}
|
package/dist/uni-push.plus.es.js
CHANGED
@@ -1,22 +1,45 @@
|
|
1
|
+
function initPushNotification() {
|
2
|
+
// 仅 App 端
|
3
|
+
if (typeof plus !== 'undefined' && plus.push) {
|
4
|
+
plus.globalEvent.addEventListener('newPath', ({ path }) => {
|
5
|
+
if (!path) {
|
6
|
+
return;
|
7
|
+
}
|
8
|
+
// 指定的页面为当前页面
|
9
|
+
const pages = getCurrentPages();
|
10
|
+
const currentPage = pages[pages.length - 1];
|
11
|
+
if (currentPage &&
|
12
|
+
currentPage.$page &&
|
13
|
+
currentPage.$page.fullPath === path) {
|
14
|
+
return;
|
15
|
+
}
|
16
|
+
// 简单起见,先尝试 navigateTo 跳转,失败后,再尝试 tabBar 跳转
|
17
|
+
uni.navigateTo({
|
18
|
+
url: path,
|
19
|
+
fail(res) {
|
20
|
+
if (res.errMsg.indexOf('tabbar') > -1) {
|
21
|
+
uni.switchTab({
|
22
|
+
url: path,
|
23
|
+
fail(res) {
|
24
|
+
console.error(res.errMsg);
|
25
|
+
},
|
26
|
+
});
|
27
|
+
}
|
28
|
+
else {
|
29
|
+
console.error(res.errMsg);
|
30
|
+
}
|
31
|
+
},
|
32
|
+
});
|
33
|
+
});
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
1
37
|
// @ts-expect-error
|
2
38
|
uni.invokePushCallback({
|
3
39
|
type: 'enabled',
|
4
40
|
offline: true,
|
5
41
|
});
|
6
42
|
Promise.resolve().then(() => {
|
43
|
+
initPushNotification();
|
7
44
|
plus.push.setAutoNotification && plus.push.setAutoNotification(false);
|
8
|
-
plus.push.addEventListener('click', (result) => {
|
9
|
-
// @ts-expect-error
|
10
|
-
uni.invokePushCallback({
|
11
|
-
type: 'click',
|
12
|
-
message: result,
|
13
|
-
});
|
14
|
-
});
|
15
|
-
plus.push.addEventListener('receive', (result) => {
|
16
|
-
// @ts-expect-error
|
17
|
-
uni.invokePushCallback({
|
18
|
-
type: 'pushMsg',
|
19
|
-
message: result,
|
20
|
-
});
|
21
|
-
});
|
22
45
|
});
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@dcloudio/uni-push",
|
3
|
-
"version": "3.0.0-alpha-
|
3
|
+
"version": "3.0.0-alpha-3060020220830001",
|
4
4
|
"description": "@dcloudio/uni-push",
|
5
5
|
"main": "lib/uni-push.js",
|
6
6
|
"module": "lib/uni-push.js",
|
@@ -20,6 +20,6 @@
|
|
20
20
|
},
|
21
21
|
"gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
|
22
22
|
"dependencies": {
|
23
|
-
"@dcloudio/uni-cli-shared": "3.0.0-alpha-
|
23
|
+
"@dcloudio/uni-cli-shared": "3.0.0-alpha-3060020220830001"
|
24
24
|
}
|
25
25
|
}
|
package/lib/.DS_Store
DELETED
Binary file
|