@dcloudio/uni-push 0.0.1-nvue3.3040020220301001 → 3.0.0-3060520221121001

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.
@@ -1,17 +1,45 @@
1
- Promise.resolve().then(() => {
2
- const info = plus.push.getClientInfo();
3
- if (info.clientid) {
4
- // @ts-expect-error
5
- uni.invokePushCallback({
6
- type: 'clientId',
7
- cid: info.clientid,
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
+ });
8
33
  });
9
34
  }
10
- plus.push.addEventListener('receive', (result) => {
11
- // @ts-expect-error
12
- uni.invokePushCallback({
13
- type: 'pushMsg',
14
- message: result,
15
- });
16
- });
35
+ }
36
+
37
+ // @ts-expect-error
38
+ uni.invokePushCallback({
39
+ type: 'enabled',
40
+ offline: true,
41
+ });
42
+ Promise.resolve().then(() => {
43
+ initPushNotification();
44
+ plus.push.setAutoNotification && plus.push.setAutoNotification(false);
17
45
  });
@@ -12,6 +12,10 @@ declare namespace GtPush {
12
12
  * 个推官网生成的appid
13
13
  */
14
14
  appid: string
15
+ /**
16
+ * 错误回调
17
+ */
18
+ onError?: (res: {error: any}) => void
15
19
  /**
16
20
  * 个推终端ID回调,标识当前终端和应用
17
21
  */