@dcloudio/uni-push 3.0.0-alpha-3050220220719001 → 3.0.0-alpha-3050320220727001

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.
@@ -100,6 +100,26 @@ e?.onClose(t);
100
100
 
101
101
  var GtPush = /*@__PURE__*/getDefaultExportFromCjs(gtpushMin);
102
102
 
103
+ function initPushNotification() {
104
+ // 仅 App 端
105
+ if (typeof plus !== 'undefined' && plus.push) {
106
+ plus.push.addEventListener('click', (result) => {
107
+ // @ts-expect-error
108
+ uni.invokePushCallback({
109
+ type: 'click',
110
+ message: result,
111
+ });
112
+ });
113
+ uni.onPushMessage((res) => {
114
+ if (res.type === 'receive' && res.data && res.data.force_notification) {
115
+ // 创建通知栏
116
+ uni.createPushMessage(res.data);
117
+ res.stopped = true;
118
+ }
119
+ });
120
+ }
121
+ }
122
+
103
123
  // if (process.env.UNI_PUSH_DEBUG) {
104
124
  // GtPush.setDebugMode(true)
105
125
  // }
@@ -119,6 +139,7 @@ if (!appid) {
119
139
  });
120
140
  }
121
141
  else {
142
+ initPushNotification();
122
143
  GtPush.init({
123
144
  appid,
124
145
  onError: (res) => {
@@ -4,14 +4,22 @@ uni.invokePushCallback({
4
4
  });
5
5
  Promise.resolve().then(() => {
6
6
  plus.push.setAutoNotification && plus.push.setAutoNotification(false);
7
- const info = plus.push.getClientInfo();
8
- if (info.clientid) {
7
+ plus.push.getClientInfoAsync((info) => {
8
+ if (info.clientid) {
9
+ // @ts-expect-error
10
+ uni.invokePushCallback({
11
+ type: 'clientId',
12
+ cid: info.clientid,
13
+ });
14
+ }
15
+ }, (res) => {
9
16
  // @ts-expect-error
10
17
  uni.invokePushCallback({
11
18
  type: 'clientId',
12
- cid: info.clientid,
19
+ cid: '',
20
+ errMsg: res.code + ': ' + res.message,
13
21
  });
14
- }
22
+ });
15
23
  plus.push.addEventListener('click', (result) => {
16
24
  // @ts-expect-error
17
25
  uni.invokePushCallback({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-push",
3
- "version": "3.0.0-alpha-3050220220719001",
3
+ "version": "3.0.0-alpha-3050320220727001",
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-3050220220719001"
23
+ "@dcloudio/uni-cli-shared": "3.0.0-alpha-3050320220727001"
24
24
  }
25
25
  }