@dcloudio/uni-push 3.0.0-alpha-3050420220804006 → 3.0.0-alpha-3050520220824001
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 +32 -0
- package/dist/uni-push.plus.es.js +53 -7
- package/package.json +2 -2
- package/lib/.DS_Store +0 -0
package/dist/uni-push.es.js
CHANGED
@@ -103,6 +103,36 @@ var GtPush = /*@__PURE__*/getDefaultExportFromCjs(gtpushMin);
|
|
103
103
|
function initPushNotification() {
|
104
104
|
// 仅 App 端
|
105
105
|
if (typeof plus !== 'undefined' && plus.push) {
|
106
|
+
plus.globalEvent.addEventListener('newPath', ({ path }) => {
|
107
|
+
if (!path) {
|
108
|
+
return;
|
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
|
+
});
|
135
|
+
});
|
106
136
|
plus.push.addEventListener('click', (result) => {
|
107
137
|
// @ts-expect-error
|
108
138
|
uni.invokePushCallback({
|
@@ -141,7 +171,9 @@ if (!appid) {
|
|
141
171
|
});
|
142
172
|
}
|
143
173
|
else {
|
174
|
+
// #ifdef APP
|
144
175
|
initPushNotification();
|
176
|
+
// #endif
|
145
177
|
GtPush.init({
|
146
178
|
appid,
|
147
179
|
onError: (res) => {
|
package/dist/uni-push.plus.es.js
CHANGED
@@ -1,17 +1,63 @@
|
|
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
|
+
plus.push.addEventListener('click', (result) => {
|
35
|
+
// @ts-expect-error
|
36
|
+
uni.invokePushCallback({
|
37
|
+
type: 'click',
|
38
|
+
message: result,
|
39
|
+
});
|
40
|
+
});
|
41
|
+
uni.onPushMessage((res) => {
|
42
|
+
if (res.type === 'receive' &&
|
43
|
+
res.data &&
|
44
|
+
res.data.force_notification) {
|
45
|
+
// 创建通知栏
|
46
|
+
uni.createPushMessage(res.data);
|
47
|
+
res.stopped = true;
|
48
|
+
}
|
49
|
+
});
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
1
53
|
// @ts-expect-error
|
2
54
|
uni.invokePushCallback({
|
3
55
|
type: 'enabled',
|
4
56
|
offline: true,
|
5
57
|
});
|
6
58
|
Promise.resolve().then(() => {
|
59
|
+
initPushNotification();
|
7
60
|
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
61
|
plus.push.addEventListener('receive', (result) => {
|
16
62
|
// @ts-expect-error
|
17
63
|
uni.invokePushCallback({
|
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-3050520220824001",
|
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-3050520220824001"
|
24
24
|
}
|
25
25
|
}
|
package/lib/.DS_Store
DELETED
Binary file
|