cordova-plugin-xinstall 1.3.3 → 1.5.5

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/README.md CHANGED
@@ -34,24 +34,112 @@ Android 不需要任何配置
34
34
 
35
35
  ## 调用API
36
36
 
37
- ### 1.快速下载
37
+ ### 1. 快速下载
38
38
 
39
39
  如果只需要快速下载功能,无需其它功能(携带参数安装、渠道统计、一键拉起),完成初始化即可(这里指安装插件)
40
40
 
41
- ### 2. 一键拉起
41
+ ### 2.初始化SDK
42
+
43
+ ```js
44
+ window.xinstall.init();
45
+ ```
46
+
47
+ ### 3. 一键拉起
42
48
 
43
49
  #### 拉起参数获取
44
50
 
45
51
  调用以下代码注册拉起回调,应尽早调用。如在 `deviceready` 事件回调之时注册
46
52
 
47
53
  ```js
54
+ // 第一种回调方法 只有是wakeup 操作才会回调------------
48
55
  window.xinstall.registerWakeUpHandler(function(data) {
49
56
  // 对data进行处理
50
57
  }, function(msg){
51
58
  console.log("xinstall.wakeup error : " + msg)
52
59
  });
60
+ // -----------------------------------------------
61
+
62
+ // 第二种回调方法, 只要调用方法,就一定有回调------------
63
+ window.xinstall.registerWakeUpDetailHandler(function(data) {
64
+ // 对data进行处理
65
+ },function(msg) {
66
+ console.log("xinstall.registerWakeUpDetailHandler : " + msg)
67
+ });
68
+ //-----------------------------------------------------
69
+ ```
70
+
71
+ 【注】:两种回调方法选择一个使用。
72
+
73
+ 两种回调返回的data格式分别为:
74
+
75
+ ```json
76
+ // 第一种回调的json 数据
77
+ {
78
+ "channelCode":"渠道编号", // 字符串类型。渠道编号,没有渠道编号时为 ""
79
+ "data":{ // 对象类型。唤起时携带的参数。
80
+ "co":{ // co 为唤醒页面中通过 Xinstall Web SDK 中的点击按钮传递的数据,key & value 均可自定义,key & value 数量不限制
81
+ "自定义key1":"自定义value1",
82
+ "自定义key2":"自定义value2"
83
+ },
84
+ "uo":{ // uo 为唤醒页面 URL 中 ? 后面携带的标准 GET 参数,key & value 均可自定义,key & value 数量不限制
85
+ "自定义key1":"自定义value1",
86
+ "自定义key2":"自定义value2"
87
+ }
88
+ }
89
+ }
90
+
91
+ // 第二种回调的json 数据
92
+ {
93
+ "wakeUpData":
94
+ {
95
+ "channelCode":"渠道编号", // 字符串类型。渠道编号,没有渠道编号时为 ""
96
+ "data":{ // 对象类型。唤起时携带的参数。
97
+ "co":{ // co 为唤醒页面中通过 Xinstall Web SDK 中的点击按钮传递的数据,key & value 均可自定义,key & value 数量不限制
98
+ "自定义key1":"自定义value1",
99
+ "自定义key2":"自定义value2"
100
+ },
101
+ "uo":{ // uo 为唤醒页面 URL 中 ? 后面携带的标准 GET 参数,key & value 均可自定义,key & value 数量不限制
102
+ "自定义key1":"自定义value1",
103
+ "自定义key2":"自定义value2"
104
+ }
105
+ }
106
+ },
107
+ "error":
108
+ {
109
+ "errorType" : 7, // 数字类型。代表错误的类型,具体数字对应类型可在下方查看
110
+ "errorMsg" : "xxxxx" // 字符串类型。错误的描述
111
+ }
112
+ }
113
+
114
+
115
+ /** errorType 对照表:
116
+ * iOS
117
+ * -1 : SDK 配置错误;
118
+ * 0 : 未知错误;
119
+ * 1 : 网络错误;
120
+ * 2 : 没有获取到数据;
121
+ * 3 : 该 App 已被 Xinstall 后台封禁;
122
+ * 4 : 该操作不被允许(一般代表调用的方法没有开通权限);
123
+ * 5 : 入参不正确;
124
+ * 6 : SDK 初始化未成功完成;
125
+ * 7 : 没有通过 Xinstall Web SDK 集成的页面拉起;
126
+ *
127
+ * Android
128
+ * 1006 : 未执行init 方法;
129
+ * 1007 : 未传入Activity,Activity 未比传参数
130
+ * 1008 : 用户未知操作 不处理
131
+ * 1009 : 不是唤醒执行的调用方法
132
+ * 1010 : 前后两次调起时间小于1s,请求过于频繁
133
+ * 1011 : 获取调起参数失败
134
+ * 1012 : 重复获取调起参数
135
+ * 1013 : 本次调起并非为XInstall的调起
136
+ * 1004 : 无权限
137
+ * 1014 : SCHEME URL 为空
138
+ */
53
139
  ```
54
140
 
141
+
142
+
55
143
  **iOS 由于使用Universal Link 技术**
56
144
 
57
145
  首先,我们需要到[苹果开发者网站](https://developer.apple.com/),为当前的 App ID 开启关联域名 (Associated Domains) 服务:
@@ -62,11 +150,13 @@ window.xinstall.registerWakeUpHandler(function(data) {
62
150
 
63
151
  ![](res/2.png)
64
152
 
65
- 在Xcode中配置Xinstall为当前应用生成的关联域名 (Associated Domains) :**applinks:xxxx.xinstall.top**
153
+ 在Xcode中配置Xinstall为当前应用生成的关联域名 (Associated Domains) :**applinks:xxxx.xinstall.top** 和 **applinks:xxxx.xinstall.net**
154
+
155
+ > 具体的关联域名可在 Xinstall管理后台 - 对应的应用控制台 - iOS下载配置 页面中找到
66
156
 
67
- ![](res/3.png)
157
+ ![](https://doc.xinstall.com/Cordova/res/3.png)
68
158
 
69
- ### 3. 携带参数安装
159
+ ### 4. 携带参数安装
70
160
 
71
161
  ```js
72
162
  window.xinstall.getInstallParams(function(data) {
@@ -87,21 +177,233 @@ window.xinstall.getInstallParams(function(data) {
87
177
  // isFirstFetch 是否第一次获取安装参数
88
178
  ```
89
179
 
90
- ### 4. 渠道统计相关
180
+ ### 5. 渠道统计相关
91
181
 
92
- #### 4.1 注册量统计
182
+ #### 5.1 注册量统计
93
183
 
94
184
  ```js
95
185
  window.xinstall.reportRegister();
96
186
  ```
97
187
 
98
- #### 4.2 渠道效果统计
188
+ #### 5.2 渠道效果统计
99
189
 
100
190
  ```js
101
191
  window.xinstall.reportEffectEvent(eventId, eventVal);
102
192
  ```
103
193
 
104
- 【注】事件需要在Xinstall 后台添加
194
+ **补充说明**
195
+
196
+ 只有 Xinstall 后台创建事件统计,并且代码中 **传递的事件ID** 与 **后台创建的ID** 一致时,上报数据才会被统计。
197
+
198
+ ### 6. 广告平台渠道功能
199
+
200
+ > 如果您在 Xinstall 管理后台对应 App 中,**只使用「自建渠道」,而不使用「广告平台渠道」,则无需进行本小节中额外的集成工作**,也能正常使用 Xinstall 提供的其他功能。
201
+ >
202
+ > 注意:根据目前已有的各大主流广告平台的统计方式,目前 iOS 端和 Android 端均需要用户授权并获取一些设备关键值后才能正常进行 [ 广告平台渠道 ] 的统计,如 IDFA / OAID / GAID 等,对该行为敏感的 App 请慎重使用该功能。
203
+
204
+ #### 6.1 配置工作
205
+
206
+ **iOS 端:**
207
+
208
+ 在 Xcode 中打开 iOS 端的工程,在 `Info.plist` 文件中配置一个权限作用声明(如果不配置将导致 App 启动后马上闪退):
209
+
210
+ ```xml
211
+ <key>NSUserTrackingUsageDescription</key>
212
+ <string>这里是针对获取 IDFA 的作用描述,请根据实际情况填写</string>
213
+ ```
214
+
215
+ 在 Xcode 中,找到 App 对应的「Target」,再点击「General」,然后在「Frameworks, Libraries, and Embedded Content」中,添加如下两个框架:
216
+
217
+ * AppTrackingTransparency.framework
218
+ * AdSupport.framework
219
+
220
+ **Android 端:**
221
+
222
+ 相关接入可以参考广告平台联调指南中的[《Android集成指南》](https://doc.xinstall.com/AD/AndroidGuide.html)
223
+
224
+ 1. 接入IMEI需要额外的全下申请,需要在`AndroidManifest`中添加权限声明
225
+
226
+ ```java
227
+ <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
228
+ ```
229
+
230
+ 2. 如果使用OAID,因为内部使用反射获取oaid 参数,所以都需要外部用户接入OAID SDK 。具体接入参考[《Android集成指南》](https://doc.xinstall.com/AD/AndroidGuide.html)
231
+
232
+
233
+
234
+ ##### 6.2、更换初始化方法
235
+
236
+ **使用新的 initWithAd 方法,替代原先的 init 方法来进行模块的初始化**
237
+
238
+ > iOS 端使用该方法时,需要传入 IDFA(在 JS 脚本内)。您可以使用任意方式在 JS 脚本中获取到 IDFA,例如第三方获取 IDFA 的模块。
239
+ >
240
+
241
+ **入参说明**:需要主动传入参数,字典
242
+
243
+ 入参内部字段:
244
+
245
+ * iOS 端:
246
+
247
+ <table>
248
+ <tr>
249
+ <th>参数名</th>
250
+ <th>参数类型</th>
251
+ <th>描述 </th>
252
+ </tr>
253
+ <tr>
254
+ <th>idfa</th>
255
+ <th>字符串</th>
256
+ <th>iOS 系统中的广告标识符</th>
257
+ </tr>
258
+ <tr>
259
+ <th>asaEnable</th>
260
+ <th>boolean</th>
261
+ <th>是否开启 ASA 渠道,不需要时可以不传。详见《8. 苹果搜索广告(ASA)渠道功能》</th>
262
+ </tr>
263
+ </table>
264
+
265
+
266
+ * Android 端:
267
+
268
+ <table>
269
+ <tr>
270
+ <th>参数名</th>
271
+ <th>参数类型</th>
272
+ <th>描述 </th>
273
+ </tr>
274
+ <tr>
275
+ <th>adEnabled</th>
276
+ <th>boolean</th>
277
+ <th>是否使用广告功能</th>
278
+ </tr>
279
+ <tr>
280
+ <th>oaid (可选)</th>
281
+ <th>string</th>
282
+ <th>OAID</th>
283
+ </tr>
284
+ <tr>
285
+ <th>gaid(可选)</th>
286
+ <th>string</th>
287
+ <th>GaID(google Ad ID)</th>
288
+ </tr>
289
+ </table>
290
+
291
+ **调用示例**
292
+
293
+ ```javascript
294
+
295
+ // oaid和gaid 为选传,不传则代表使用SDK自动去获取(SDK内不包括OAID SDK,需要自己接入)
296
+ window.xinstall.initWithAd({adEnabled:true,idfa:"idfa需要自己传入",oaid:"oaid测试",gaid:"测试",asaEnable:true});
297
+ // 如果希望在完成初始化,立即执行之后的步骤可以通过 下列代码实现-------------------------
298
+ //window.xinstall.initWithAd({adEnable:true,idfa:"外部获取的idfa",asaEnable:true},function() {
299
+ // window.xinstall.getInstallParams 或者 window.xinstall.registerWakeUpHandler 等操作
300
+ //});
301
+ //-----------------------------------------------------------------------------
302
+
303
+ ```
304
+
305
+ ##### 7.3、上架须知
306
+
307
+ **在使用了广告平台渠道后,若您的 App 需要上架,请认真阅读本段内容。**
308
+
309
+ ##### 7.3.1 iOS 端:上架 App Store
310
+
311
+ 1. 如果您的 App 没有接入苹果广告(即在 App 中显示苹果投放的广告),那么在提交审核时,在广告标识符中,请按照下图勾选:
312
+
313
+ ![IDFA](https://cdn.xinstall.com/iOS_SDK%E7%B4%A0%E6%9D%90/IDFA_7.png)
314
+
315
+
316
+
317
+ 1. 在 App Store Connect 对应 App —「App隐私」—「数据类型」选项中,需要选择:**“是,我们会从此 App 中收集数据”**:
318
+
319
+ ![AppStore_IDFA_1](https://cdn.xinstall.com/iOS_SDK%E7%B4%A0%E6%9D%90/IDFA_1.png)
320
+
321
+ 在下一步中,勾选「设备 ID」并点击【发布】按钮:
322
+
323
+ ![AppStore_IDFA_2](https://cdn.xinstall.com/iOS_SDK%E7%B4%A0%E6%9D%90/IDFA_2.png)
324
+
325
+ 点击【设置设备 ID】按钮后,在弹出的弹框中,根据实际情况进行勾选:
326
+
327
+ - 如果您仅仅是接入了 Xinstall 广告平台而使用了 IDFA,那么只需要勾选:**第三方广告**
328
+ - 如果您在接入 Xinstall 广告平台之外,还自行使用 IDFA 进行别的用途,那么在勾选 **第三方广告** 后,还需要您根据您的实际使用情况,进行其他选项的勾选
329
+
330
+ ![AppStore_IDFA_3](https://cdn.xinstall.com/iOS_SDK%E7%B4%A0%E6%9D%90/IDFA_3.png)
331
+
332
+ ![AppStore_IDFA_4](https://cdn.xinstall.com/iOS_SDK%E7%B4%A0%E6%9D%90/IDFA_4.png)
333
+
334
+ 勾选完成后点击【下一步】按钮,在 **“从此 App 中收集的设备 ID 是否与用户身份关联?”** 选项中,请根据如下情况进行选择:
335
+
336
+ - 如果您仅仅是接入了 Xinstall 广告平台而使用了 IDFA,那么选择 **“否,从此 App 中收集的设备 ID 未与用户身份关联”**
337
+ - 如果您在接入 Xinstall 广告平台之外,还自行使用 IDFA 进行别的用途,那么请根据您的实际情况选择对应的选项
338
+
339
+ ![AppStore_IDFA_5](https://cdn.xinstall.com/iOS_SDK%E7%B4%A0%E6%9D%90/IDFA_5.png)
340
+
341
+ 最后,在弹出的弹框中,选择 **“是,我们会将设备 ID 用于追踪目的”**,并点击【发布】按钮:
342
+
343
+ ![AppStore_IDFA_6](https://cdn.xinstall.com/iOS_SDK%E7%B4%A0%E6%9D%90/IDFA_6.png)
344
+
345
+ ##### 7.3.2 Android 端
346
+
347
+ 无特殊需要注意,如碰上相关合规问题,参考 [《应用合规指南》](https://doc.xinstall.com/应用合规指南.html)
348
+
349
+ ### 8. 苹果搜索广告(ASA)渠道功能
350
+
351
+ > 如果您在 Xinstall 管理后台对应 App 中,**不使用「ASA渠道」,则无需进行本小节中额外的集成工作**,也能正常使用 Xinstall 提供的其他功能。
352
+
353
+ #### 8.1 更换初始化方法
354
+
355
+ **使用新的 initWithAd 方法,替代原先的 init 方法来进行模块的初始化**
356
+
357
+ ## **initWithAd**
358
+
359
+ **入参说明**:需要主动传入参数,JSON对象
360
+
361
+ 入参内部字段:
362
+
363
+ * iOS 端:
364
+
365
+ <table>
366
+ <tr>
367
+ <th>参数名</th>
368
+ <th>参数类型</th>
369
+ <th>描述 </th>
370
+ </tr>
371
+ <tr>
372
+ <th>idfa</th>
373
+ <th>string</th>
374
+ <th>iOS 系统中的广告标识符(不需要时可以不传)</th>
375
+ </tr>
376
+ <tr>
377
+ <th>asaEnable</th>
378
+ <th>boolean</th>
379
+ <th>是否开启 ASA 渠道,true 时为开启,false 或者不传时均为不开启</th>
380
+ </tr>
381
+ </table>
382
+
383
+ **回调说明**:无需传入回调函数
384
+
385
+ **调用示例**
386
+
387
+ ```javascript
388
+ // idfa 为广告传入参数,如果未使用到,可以不传入
389
+ window.xinstall.initWithAd({asaEnable:true},function() {
390
+ // 初始化回调 为选传参数
391
+ window.xinstall.getInstallParams(function(data){
392
+
393
+ }, 10);
394
+ });
395
+
396
+ ```
397
+
398
+ **可用性**
399
+
400
+ iOS系统
401
+
402
+ 可提供的 1.5.5 及更高版本
403
+
404
+
405
+
406
+
105
407
 
106
408
  ## 导出apk/ipa包并上传
107
409
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cordova-plugin-xinstall",
3
- "version": "1.3.3",
3
+ "version": "1.5.5",
4
4
  "description": "Xinstall 为了用户更方便的接入SDK,基于原生SDK封装的CordovaSDK",
5
5
  "cordova": {
6
6
  "id": "cordova-plugin-xinstall",
package/plugin.xml CHANGED
@@ -1,5 +1,5 @@
1
1
  <?xml version="1.0" encoding="UTF-8" ?>
2
- <plugin id="cordova-plugin-xinstall" version="1.3.2"
2
+ <plugin id="cordova-plugin-xinstall" version="1.5.5"
3
3
  xmlns="http://phonegap.com/ns/plugins/1.0"
4
4
  xmlns:android="http://schemas.android.com/apk/res/android"
5
5
  >
@@ -1,14 +1,18 @@
1
1
  package io.xinstall.cordova;// TOM
2
2
 
3
3
  import android.app.Activity;
4
- import android.app.AlertDialog;
5
4
  import android.content.Intent;
5
+ import android.os.Handler;
6
+ import android.os.Looper;
6
7
  import android.text.TextUtils;
7
8
  import android.util.Log;
9
+
10
+ import com.xinstall.XINConfiguration;
8
11
  import com.xinstall.XInstall;
9
12
  import com.xinstall.listener.XInstallAdapter;
10
13
  import com.xinstall.listener.XWakeUpAdapter;
11
14
  import com.xinstall.model.XAppData;
15
+ import com.xinstall.model.XAppError;
12
16
 
13
17
  import org.apache.cordova.CallbackContext;
14
18
  import org.apache.cordova.CordovaArgs;
@@ -24,25 +28,31 @@ public class XinstallPlugin extends CordovaPlugin {
24
28
  public static final String XinstallPlugin = "XinstallPlugin";
25
29
 
26
30
  private CallbackContext wakeupCallbackContext = null;
31
+ private XAppData wakeupAppData = null;
32
+ private XAppError wakeupAppError = null;
33
+
34
+ private Intent wakeupIntent = null;
35
+ private Activity wakeupActivity = null;
36
+
37
+ private boolean hasCallInit = false;
38
+ private boolean initialized = false;
39
+ private boolean registerWakeup = false;
40
+ private Integer wakeupType = 0;
27
41
 
28
- private boolean isOpenYyb = false;
42
+ private static final Handler UIHandler = new Handler(Looper.getMainLooper());
29
43
 
30
44
  @Override
31
45
  protected void pluginInitialize() {
32
46
  super.pluginInitialize();
33
- init();
47
+ getWakeUpParams(cordova.getActivity(),cordova.getActivity().getIntent());
34
48
  }
35
49
 
36
50
  @Override
37
51
  public void onNewIntent(Intent intent) {
38
52
  super.onNewIntent(intent);
39
- if (wakeupCallbackContext != null) {
40
- getWakeUpParams(cordova.getActivity(),intent, wakeupCallbackContext);
41
- }
53
+ getWakeUpParams(cordova.getActivity(),intent);
42
54
  }
43
55
 
44
-
45
-
46
56
  @Override
47
57
  public boolean execute(String action, CordovaArgs args, CallbackContext callbackContext) throws JSONException {
48
58
  Log.d(XinstallPlugin,"execute action =" + action);
@@ -52,56 +62,276 @@ public class XinstallPlugin extends CordovaPlugin {
52
62
  }
53
63
 
54
64
  if ("getInstallParams".equals(action)) {
55
- getInstallParams(args, callbackContext);
65
+ runInUIThread(new Runnable() {
66
+ @Override
67
+ public void run() {
68
+ getInstallParams(args, callbackContext);
69
+ }
70
+ });
56
71
  return true;
57
72
  } else if ("registerWakeUpHandler".equals(action)) {
58
- registerWakeUpHandler(callbackContext);
73
+ runInUIThread(new Runnable() {
74
+ @Override
75
+ public void run() {
76
+ registerWakeUpHandler(callbackContext);
77
+ }
78
+ });
79
+ return true;
80
+ } else if ("registerWakeUpDetailHandler".equals(action)) {
81
+ runInUIThread(new Runnable() {
82
+ @Override
83
+ public void run() {
84
+ registerWakeUpDetailHandler(callbackContext);
85
+ }
86
+ });
59
87
  return true;
60
88
  } else if ("reportRegister".equals(action)) {
61
- reportRegister(callbackContext);
89
+ runInUIThread(new Runnable() {
90
+ @Override
91
+ public void run() {
92
+ reportRegister(callbackContext);
93
+ }
94
+ });
95
+
62
96
  return true;
63
97
  } else if ("reportEffectEvent".equals(action)) {
64
- reportEffectEvent(args, callbackContext);
98
+ runInUIThread(new Runnable() {
99
+ @Override
100
+ public void run() {
101
+ reportEffectEvent(args, callbackContext);
102
+ }
103
+ });
104
+ return true;
105
+ } else if ("reportShareByXinShareId".equals(action)) {
106
+ runInUIThread(new Runnable() {
107
+ @Override
108
+ public void run() {
109
+ reportShareByXinShareId(args, callbackContext);
110
+ }
111
+ });
112
+ return true;
113
+ } else if ("initNoAd".equals(action)) {
114
+ runInUIThread(new Runnable() {
115
+ @Override
116
+ public void run() {
117
+ initNoAd();
118
+ }
119
+ });
65
120
  return true;
66
- } else if ("openYybWakeUp".equals(action)) {
67
- openYybWakeUp(callbackContext);
121
+ } else if ("initWithAd".equals(action)){
122
+ runInUIThread(new Runnable() {
123
+ @Override
124
+ public void run() {
125
+ initWithAd(args,callbackContext);
126
+ }
127
+ });
128
+ return true;
129
+ } else if ("setLog".equals(action)) {
130
+ runInUIThread(new Runnable() {
131
+ @Override
132
+ public void run() {
133
+ setLog(args);
134
+ }
135
+ });
68
136
  return true;
69
137
  }
70
-
71
138
  return false;
72
139
  }
73
140
 
74
- protected void init() {
141
+ private static void runInUIThread(Runnable runnable) {
142
+ if (Looper.myLooper() == Looper.getMainLooper()) {
143
+ // 当前线程为UI主线程
144
+ runnable.run();
145
+ } else {
146
+ UIHandler.post(runnable);
147
+ }
148
+ }
149
+
150
+ protected void setLog(CordovaArgs args) {
151
+ if (args != null && !args.isNull(0)) {
152
+ Log.d(XinstallPlugin,"setLog");
153
+ boolean isOpen = args.optBoolean(0);
154
+ XInstall.setDebug(isOpen);
155
+ }
156
+ }
157
+
158
+ protected void initNoAd() {
159
+ hasCallInit = true;
75
160
  Log.d(XinstallPlugin,"init");
76
161
  XInstall.init(cordova.getContext());
162
+ initialized();
77
163
  }
78
-
79
- private void getWakeUpParams(Activity activity, Intent intent, final CallbackContext callbackContext) {
80
- if ((intent.getCategories() != null && intent.getCategories().contains(Intent.CATEGORY_LAUNCHER)) && this.isOpenYyb == false) {
81
- return;
164
+
165
+ protected void initWithAd(CordovaArgs args, final CallbackContext callbackContext) {
166
+ hasCallInit = true;
167
+ Log.d(XinstallPlugin,"initWithAd");
168
+ boolean adEnable = false;
169
+ if (args != null && !args.isNull(0)) {
170
+ adEnable = args.optBoolean(0);
171
+ }
172
+ String oaid = "";
173
+ if (args != null && !args.isNull(1)) {
174
+ oaid = args.optString(1);
175
+ }
176
+ String gaid = "";
177
+ if (args != null && !args.isNull(2)) {
178
+ gaid = args.optString(2);
179
+ }
180
+ boolean isPremission = true;
181
+ if (args != null && !args.isNull(3)) {
182
+ isPremission = args.optBoolean(3);
82
183
  }
83
184
 
84
- Log.d(XinstallPlugin,"getWakeUpParams intent : " + intent.getDataString());
85
- XInstall.getWakeUpParam(activity, intent, new XWakeUpAdapter() {
86
- @Override
87
- public void onWakeUp(XAppData xAppData) {
88
- if (xAppData != null) {
89
- JSONObject jsonObject = xAppData.toJsonObject();
185
+ final XINConfiguration configuration = XINConfiguration.Builder().adEnable(true);
186
+ if (!"".equals(gaid)) {
187
+ configuration.gaid(gaid);
188
+ }
189
+ if (!"".equals(oaid)) {
190
+ configuration.oaid(oaid);
191
+ }
90
192
 
91
- PluginResult result = new PluginResult(PluginResult.Status.OK, jsonObject);
92
- result.setKeepCallback(true);
93
- callbackContext.sendPluginResult(result);
94
- } else {
95
- PluginResult result = new PluginResult(PluginResult.Status.OK);
96
- result.setKeepCallback(true);
97
- callbackContext.sendPluginResult(result);
193
+ if (isPremission) {
194
+ XInstall.initWithPermission(cordova.getContext(), configuration, new Runnable() {
195
+ @Override
196
+ public void run() {
197
+ initialized();
198
+ callbackContext.success();
98
199
  }
200
+ });
201
+ } else {
202
+ XInstall.init(cordova.getContext(),configuration);
203
+ initialized();
204
+ callbackContext.success();
205
+ }
206
+ }
207
+
208
+ private void initialized() {
209
+ initialized = true;
210
+ if (wakeupIntent != null && wakeupActivity != null) {
211
+ if (wakeupType == 1) {
212
+ XInstall.getWakeUpParam(wakeupActivity, wakeupIntent, new XWakeUpAdapter() {
213
+ @Override
214
+ public void onWakeUp(XAppData xAppData) {
215
+ if (xAppData != null) {
216
+
217
+ JSONObject jsonObject = xAppData.toJsonObject();
218
+
219
+ Log.d(XinstallPlugin, jsonObject.toString());
220
+ if (!registerWakeup) {
221
+ Log.d(XinstallPlugin, "没有注册 wakeupCallback");
222
+ wakeupAppData = xAppData;
223
+ wakeupAppError = null;
224
+ return;
225
+ }
226
+
227
+ PluginResult result = new PluginResult(PluginResult.Status.OK, jsonObject);
228
+ result.setKeepCallback(true);
229
+ wakeupCallbackContext.sendPluginResult(result);
230
+ } else {
231
+ if (!registerWakeup) {
232
+ Log.d(XinstallPlugin, "没有注册 wakeupCallback");
233
+ wakeupAppData = null;
234
+ wakeupAppError = null;
235
+ return;
236
+ }
237
+ PluginResult result = new PluginResult(PluginResult.Status.OK);
238
+ result.setKeepCallback(true);
239
+ wakeupCallbackContext.sendPluginResult(result);
240
+ }
241
+ }
242
+ });
243
+ } else if (wakeupType == 2) {
244
+ XInstall.getWakeUpParamEvenErrorAlsoCallBack(wakeupActivity, wakeupIntent, new XWakeUpAdapter() {
245
+ @Override
246
+ public void onWakeUpFinish(XAppData xAppData, XAppError xAppError) {
247
+ super.onWakeUpFinish(xAppData, xAppError);
248
+ JSONObject jsonObject = toJsonObjectHasError(xAppData,xAppError);
249
+
250
+ Log.d(XinstallPlugin, jsonObject.toString());
251
+ if (!registerWakeup) {
252
+ Log.d(XinstallPlugin, "没有注册 wakeupDetailCallback");
253
+ wakeupAppData = xAppData;
254
+ wakeupAppError = xAppError;
255
+ return;
256
+ }
257
+
258
+ PluginResult result = new PluginResult(PluginResult.Status.OK, jsonObject);
259
+ result.setKeepCallback(true);
260
+ wakeupCallbackContext.sendPluginResult(result);
261
+ }
262
+ });
99
263
  }
100
- });
264
+
265
+ }
266
+ }
267
+
268
+ private void getWakeUpParams(Activity activity, Intent intent) {
269
+ if (initialized) {
270
+ Log.d(XinstallPlugin,"getWakeUpParams intent : " + intent.getDataString());
271
+ if (wakeupType == 1) {
272
+ XInstall.getWakeUpParam(activity, intent, new XWakeUpAdapter() {
273
+ @Override
274
+ public void onWakeUp(XAppData xAppData) {
275
+ if (xAppData != null) {
276
+
277
+ JSONObject jsonObject = xAppData.toJsonObject();
278
+
279
+ Log.d(XinstallPlugin, jsonObject.toString());
280
+ if (!registerWakeup) {
281
+ Log.d(XinstallPlugin, "没有注册 wakeupCallback");
282
+ wakeupAppData = xAppData;
283
+ wakeupAppError = null;
284
+ return;
285
+ }
286
+
287
+ PluginResult result = new PluginResult(PluginResult.Status.OK, jsonObject);
288
+ result.setKeepCallback(true);
289
+ wakeupCallbackContext.sendPluginResult(result);
290
+ } else {
291
+ if (!registerWakeup) {
292
+ Log.d(XinstallPlugin, "没有注册 wakeupCallback");
293
+ wakeupAppData = null;
294
+ wakeupAppError = null;
295
+ return;
296
+ }
297
+ PluginResult result = new PluginResult(PluginResult.Status.OK);
298
+ result.setKeepCallback(true);
299
+ wakeupCallbackContext.sendPluginResult(result);
300
+ }
301
+ }
302
+ });
303
+ } else {
304
+ XInstall.getWakeUpParamEvenErrorAlsoCallBack(activity, intent, new XWakeUpAdapter() {
305
+ @Override
306
+ public void onWakeUpFinish(XAppData xAppData, XAppError xAppError) {
307
+ super.onWakeUpFinish(xAppData, xAppError);
308
+ JSONObject jsonObject = toJsonObjectHasError(xAppData,xAppError);
309
+
310
+ Log.d(XinstallPlugin, jsonObject.toString());
311
+ if (!registerWakeup) {
312
+ Log.d(XinstallPlugin, "没有注册 wakeupDetailCallback");
313
+ wakeupAppData = xAppData;
314
+ wakeupAppError = xAppError;
315
+ return;
316
+ }
317
+
318
+ PluginResult result = new PluginResult(PluginResult.Status.OK, jsonObject);
319
+ result.setKeepCallback(true);
320
+ wakeupCallbackContext.sendPluginResult(result);
321
+ }
322
+ });
323
+ }
324
+
325
+ } else {
326
+ wakeupIntent = intent;
327
+ wakeupActivity = activity;
328
+ }
329
+
330
+
101
331
  }
102
332
 
103
333
  protected void getInstallParams(CordovaArgs args, final CallbackContext callbackContext) {
104
- int timeout = -1;
334
+ int timeout = 0;
105
335
  if (args != null && !args.isNull(0)) {
106
336
  timeout = args.optInt(0);
107
337
  }
@@ -122,10 +352,6 @@ public class XinstallPlugin extends CordovaPlugin {
122
352
  });
123
353
  }
124
354
 
125
- protected void openYybWakeUp(final CallbackContext callbackContext) {
126
- this.isOpenYyb = true;
127
- }
128
-
129
355
  protected void reportRegister(final CallbackContext callbackContext) {
130
356
  Log.d(XinstallPlugin, "reportRegister");
131
357
  XInstall.reportRegister();
@@ -135,31 +361,116 @@ public class XinstallPlugin extends CordovaPlugin {
135
361
  if (args != null && !args.isNull(0) && !args.isNull(1)) {
136
362
  String eventId = args.optString(0);
137
363
  long eventValue = args.optLong(1);
364
+
365
+ if (eventId.length() == 0) {
366
+ Log.d(XinstallPlugin,"eventId 参数不得为空");
367
+ return;
368
+ }
369
+
370
+ if (eventValue == 0) {
371
+ Log.d(XinstallPlugin,"eventValue 参数不得为空");
372
+ return;
373
+ }
374
+
138
375
  Log.d(XinstallPlugin, "reportEffectEvent # eventId:" + eventId + ", eventValue:" + eventValue);
139
- XInstall.reportPoint(eventId, (int) eventValue);
376
+ XInstall.reportEvent(eventId, (int) eventValue);
140
377
  }
141
378
  }
379
+
380
+ protected void reportShareByXinShareId(CordovaArgs args, final CallbackContext callbackContext) {
381
+ if (args != null && !args.isNull(0)) {
382
+ String userId = args.optString(0);
383
+ if (userId.length() == 0) {
384
+ Log.d(XinstallPlugin,"userId 参数不得为空");
385
+ return;
386
+ }
387
+ Log.d(XinstallPlugin, "reportShareByXinShareId # userId:" + userId + ", userId:" + userId);
388
+ XInstall.reportShareByXinShareId(userId);
389
+ }
390
+ }
142
391
 
143
392
  protected void registerWakeUpHandler(CallbackContext callbackContext) {
393
+ if (!hasCallInit) {
394
+ Log.d(XinstallPlugin,"未执行SDK 初始化方法, SDK 需要手动初始化(初始方法为 init 和 initWithAd !)");
395
+ return;
396
+ }
397
+
398
+ if (wakeupType == 2) {
399
+ Log.d(XinstallPlugin, "registerWakeup 与 registerWakeupDetail 为互斥方法,择一选择使用");
400
+ }
401
+
402
+ wakeupType = 1;
403
+
144
404
  //只能注册一个回调
405
+ registerWakeup = true;
145
406
  this.wakeupCallbackContext = callbackContext;
146
- PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT);
147
- result.setKeepCallback(true);
148
- callbackContext.sendPluginResult(result);
149
407
 
150
- Intent intent = cordova.getActivity().getIntent();
151
- if (intent == null)
152
- {
408
+ if (wakeupCallbackContext != null && wakeupAppData != null) {
409
+ JSONObject result = wakeupAppData.toJsonObject();
410
+ PluginResult resultOfPlugin = new PluginResult(PluginResult.Status.OK, result);
411
+ resultOfPlugin.setKeepCallback(true);
412
+ wakeupCallbackContext.sendPluginResult(resultOfPlugin);
413
+
414
+ } else {
415
+ PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT);
416
+ result.setKeepCallback(true);
417
+ callbackContext.sendPluginResult(result);
418
+ getWakeUpParams(cordova.getActivity(),cordova.getActivity().getIntent());
419
+ }
420
+ }
421
+
422
+ protected void registerWakeUpDetailHandler(CallbackContext callbackContext) {
423
+ if (!hasCallInit) {
424
+ Log.d(XinstallPlugin,"未执行SDK 初始化方法, SDK 需要手动初始化(初始方法为 init 和 initWithAd !)");
153
425
  return;
154
426
  }
155
427
 
156
- if (intent.getAction().equals(Intent.ACTION_VIEW)) {
157
- if (TextUtils.isEmpty(intent.getDataString())) {
158
- return;
428
+ if (wakeupType == 1) {
429
+ Log.d(XinstallPlugin, "registerWakeup 与 registerWakeupDetail 为互斥方法,择一选择使用");
430
+ }
431
+
432
+ wakeupType = 2;
433
+
434
+ //只能注册一个回调
435
+ registerWakeup = true;
436
+ this.wakeupCallbackContext = callbackContext;
437
+
438
+ if (wakeupCallbackContext != null && (wakeupAppData != null || wakeupAppError != null)) {
439
+ JSONObject result = toJsonObjectHasError(wakeupAppData,wakeupAppError);
440
+ PluginResult resultOfPlugin = new PluginResult(PluginResult.Status.OK, result);
441
+ resultOfPlugin.setKeepCallback(true);
442
+ wakeupCallbackContext.sendPluginResult(resultOfPlugin);
443
+ } else {
444
+ PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT);
445
+ result.setKeepCallback(true);
446
+ callbackContext.sendPluginResult(result);
447
+ getWakeUpParams(cordova.getActivity(),cordova.getActivity().getIntent());
448
+ }
449
+ }
450
+
451
+ private JSONObject toJsonObjectHasError(XAppData xAppData, XAppError xAppError) {
452
+
453
+ JSONObject wakeUpData = new JSONObject();
454
+ if (xAppData != null) {
455
+ wakeUpData = xAppData.toJsonObject();
456
+ }
457
+ JSONObject error = new JSONObject();
458
+ if (xAppError != null) {
459
+ try {
460
+ error.put("errorType",xAppError.getErrorCode());
461
+ error.put("errorMsg",xAppError.getErrorMsg());
462
+ } catch (Exception e) {
463
+
159
464
  }
160
465
  }
161
- if (wakeupCallbackContext != null) {
162
- getWakeUpParams(cordova.getActivity(), this.cordova.getActivity().getIntent(), wakeupCallbackContext);
466
+ JSONObject result = new JSONObject();
467
+ try {
468
+ result.put("wakeUpData",wakeUpData);
469
+ result.put("error",error);
470
+ } catch (Exception e) {
471
+
163
472
  }
473
+ return result;
164
474
  }
165
475
  }
476
+
Binary file
@@ -14,11 +14,19 @@ NS_ASSUME_NONNULL_BEGIN
14
14
  @property (nonatomic, strong) NSString *appKey;
15
15
 
16
16
  // 给Cordova调用的方法
17
+
17
18
  - (void)getInstallParams:(CDVInvokedUrlCommand *)command;
18
19
  - (void)registerWakeUpHandler:(CDVInvokedUrlCommand *)command;
19
20
  - (void)reportRegister:(CDVInvokedUrlCommand *)command;
20
21
  - (void)reportEffectEvent:(CDVInvokedUrlCommand *)command;
21
22
 
23
+ - (void)setLog:(CDVInvokedUrlCommand *)command;
24
+ - (void)initNoAd:(CDVInvokedUrlCommand *)command;
25
+ - (void)initWithAd:(CDVInvokedUrlCommand *)command;
26
+
27
+ - (void)registerWakeUpDetailHandler:(CDVInvokedUrlCommand *)command;
28
+ - (void)reportShareByXinShareId:(CDVInvokedUrlCommand *)command;
29
+
22
30
  // AppDelegate+Xinstall 中会调用
23
31
  - (BOOL)continueUserActivity:(NSUserActivity *_Nullable)userActivity;
24
32
 
@@ -6,16 +6,23 @@
6
6
  //
7
7
 
8
8
  #import "CDVXinstall.h"
9
+ #if __has_include(<AdServices/AAAttribution.h>)
10
+ #import <AdServices/AAAttribution.h>
11
+ #endif
9
12
 
10
- NSString * const XinstallThirdVersion = @"XINSTALL_THIRDSDKVERSION_1.3.3_THIRDSDKVERSION_XINSTALL";
13
+ NSString * const XinstallThirdVersion = @"XINSTALL_THIRDSDKVERSION_1.5.5_THIRDSDKVERSION_XINSTALL";
11
14
  NSString * const XinstallThirdPlatform = @"XINSTALL_THIRDPLATFORM_CORDOVA_THIRDPLATFORM_XINSTALL";
12
15
 
13
16
  @interface CDVXinstall()
14
17
 
15
18
  @property (nonatomic, strong) NSMutableArray *marrWakeUpCallbackId;
16
19
 
20
+ @property (nonatomic, strong) NSMutableArray *marrWakeUpDetailCallbackId;
21
+
17
22
  @property (nonatomic, strong) NSDictionary *dicWakeUp;
18
23
 
24
+ @property (nonatomic, strong) NSDictionary *dicWakeUpDetail;
25
+
19
26
  @end
20
27
 
21
28
  @implementation CDVXinstall
@@ -69,7 +76,6 @@ NSString * const XinstallThirdPlatform = @"XINSTALL_THIRDPLATFORM_CORDOVA_THIRDP
69
76
  if (appKey){
70
77
  //暂时没有使用 传入的appKey
71
78
  self.appKey = appKey;
72
- [XinstallSDK initWithDelegate:self];
73
79
  NSLog(@"%@",XinstallThirdVersion);
74
80
  NSLog(@"%@",XinstallThirdPlatform);
75
81
  }
@@ -87,6 +93,50 @@ NSString * const XinstallThirdPlatform = @"XINSTALL_THIRDPLATFORM_CORDOVA_THIRDP
87
93
  }
88
94
  }
89
95
 
96
+
97
+ - (void)setLog:(CDVInvokedUrlCommand *)command {
98
+ if (command.arguments.count != 0) {
99
+ // 有参数
100
+ BOOL isOpen = [command.arguments objectAtIndex:0];
101
+ [XinstallSDK setShowLog:isOpen];
102
+ }
103
+ }
104
+
105
+ - (void)initNoAd:(CDVInvokedUrlCommand *)command {
106
+ [XinstallSDK initWithDelegate:self];
107
+ }
108
+
109
+ + (NSString *)getASAToken {
110
+ #if __has_include(<AdServices/AAAttribution.h>)
111
+ if (@available(iOS 14.3, *)) {
112
+ NSError *error;
113
+ NSString *asaToken = [AAAttribution attributionTokenWithError:&error];
114
+ return asaToken;
115
+ } else {
116
+ return @"";
117
+ }
118
+ #else
119
+ return @"";
120
+ #endif
121
+ }
122
+
123
+ - (void)initWithAd:(CDVInvokedUrlCommand *)command {
124
+ if (command.arguments.count >= 6) {
125
+ // 有idfa参数
126
+ NSString *idfa = [command.arguments objectAtIndex:4];
127
+ Boolean asaEnable = [[command.arguments objectAtIndex:5] boolValue];
128
+ NSString *asaToken = @"";
129
+ if (asaEnable) {
130
+ asaToken = [CDVXinstall getASAToken];
131
+ }
132
+
133
+ [XinstallSDK initWithDelegate:self idfa:idfa asaToken:asaToken];
134
+
135
+ CDVPluginResult *commandResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:@{}];
136
+ [self.commandDelegate sendPluginResult:commandResult callbackId:command.callbackId];
137
+ }
138
+ }
139
+
90
140
  - (void)getInstallParams:(CDVInvokedUrlCommand *)command {
91
141
  __weak __typeof(self) weakSelf = self;
92
142
  [[XinstallSDK defaultManager] getInstallParamsWithCompletion:^(XinstallData * _Nullable installData, XinstallError * _Nullable error) {
@@ -137,6 +187,7 @@ NSString * const XinstallThirdPlatform = @"XINSTALL_THIRDPLATFORM_CORDOVA_THIRDP
137
187
 
138
188
  }
139
189
  CDVPluginResult *commandResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[installMsgDic copy]];
190
+ [commandResult setKeepCallbackAsBool:YES];
140
191
  [self.commandDelegate sendPluginResult:commandResult callbackId:command.callbackId];
141
192
  }];
142
193
  }
@@ -148,6 +199,7 @@ NSString * const XinstallThirdPlatform = @"XINSTALL_THIRDPLATFORM_CORDOVA_THIRDP
148
199
  // 调起已执行,并有数据
149
200
  [self.marrWakeUpCallbackId addObject:command.callbackId];
150
201
  CDVPluginResult *commandResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[self.dicWakeUp copy]];
202
+ [commandResult setKeepCallbackAsBool:YES];
151
203
  [self.commandDelegate sendPluginResult:commandResult callbackId:command.callbackId];
152
204
  self.dicWakeUp = nil;
153
205
  } else {
@@ -176,6 +228,30 @@ NSString * const XinstallThirdPlatform = @"XINSTALL_THIRDPLATFORM_CORDOVA_THIRDP
176
228
  }
177
229
  }
178
230
 
231
+ - (void)registerWakeUpDetailHandler:(CDVInvokedUrlCommand *)command {
232
+ if (self.dicWakeUpDetail) {
233
+ // 调起已执行,并有数据
234
+ [self.marrWakeUpDetailCallbackId addObject:command.callbackId];
235
+ CDVPluginResult *commandResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[self.dicWakeUpDetail copy]];
236
+ [commandResult setKeepCallbackAsBool:YES];
237
+ [self.commandDelegate sendPluginResult:commandResult callbackId:command.callbackId];
238
+ self.dicWakeUpDetail = nil;
239
+ } else {
240
+ [self.marrWakeUpDetailCallbackId addObject:command.callbackId];
241
+ }
242
+
243
+ }
244
+ - (void)reportShareByXinShareId:(CDVInvokedUrlCommand *)command {
245
+ NSString *shareId = @"";
246
+ if (command.arguments.count != 0) {
247
+ id userId = [command.arguments objectAtIndex:0];
248
+ if ([userId isKindOfClass:[NSString class]]) {
249
+ shareId = userId;
250
+ }
251
+ [[XinstallSDK defaultManager] reportShareByXinShareId:shareId];
252
+ }
253
+ }
254
+
179
255
  #pragma mark - Tools methods
180
256
  - (NSString *)jsonStringWithObject:(id)jsonObject{
181
257
 
@@ -206,8 +282,7 @@ NSString * const XinstallThirdPlatform = @"XINSTALL_THIRDPLATFORM_CORDOVA_THIRDP
206
282
  }
207
283
 
208
284
  #pragma mark - XinstallDelegate methods
209
- - (void)xinstall_getWakeUpParams:(XinstallData *)appData {
210
-
285
+ - (void)xinstall_getWakeUpParams:(XinstallData *)appData error:(XinstallError *)error {
211
286
  NSDictionary *wakeMsgDic = @{};
212
287
 
213
288
  if (![CDVXinstall isEmptyData:appData]) {
@@ -253,20 +328,44 @@ NSString * const XinstallThirdPlatform = @"XINSTALL_THIRDPLATFORM_CORDOVA_THIRDP
253
328
  }
254
329
 
255
330
  wakeMsgDic = @{@"channelCode": channelCode,@"timeSpan":timeSpan, @"data": dataDic};
331
+
332
+ if (self.marrWakeUpCallbackId.count > 0) {
333
+ self.dicWakeUp = nil;
334
+ for (int i = 0; i < self.marrWakeUpCallbackId.count; i++) {
335
+ NSString *callBackId = [self.marrWakeUpCallbackId objectAtIndex:i];
336
+ CDVPluginResult *commandResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[wakeMsgDic copy]];
337
+ [commandResult setKeepCallbackAsBool:YES];
338
+ [self.commandDelegate sendPluginResult:commandResult callbackId:callBackId];
339
+ }
340
+ } else {
341
+ @synchronized (self) {
342
+ self.dicWakeUp = wakeMsgDic;
343
+ }
344
+ }
345
+ }
346
+ NSDictionary *mdicError = @{};
347
+ if (error != nil) {
348
+ mdicError = @{@"errorType":@(error.type),@"errorMsg":error.errorMsg};
256
349
  }
257
350
 
351
+ NSDictionary *dicWakeupDetail = @{@"wakeUpData":wakeMsgDic,@"error":mdicError};
258
352
 
259
- if (self.marrWakeUpCallbackId.count > 0) {
260
- for (int i = 0; i < self.marrWakeUpCallbackId.count; i++) {
261
- NSString *callBackId = [self.marrWakeUpCallbackId objectAtIndex:i];
262
- CDVPluginResult *commandResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[wakeMsgDic copy]];
353
+ if (self.marrWakeUpDetailCallbackId.count > 0) {
354
+ self.dicWakeUpDetail = nil;
355
+ for (int i = 0; i < self.marrWakeUpDetailCallbackId.count ; i++) {
356
+ NSString *callBackId = [self.marrWakeUpDetailCallbackId objectAtIndex:i];
357
+ CDVPluginResult *commandResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[dicWakeupDetail copy]];
358
+ [commandResult setKeepCallbackAsBool:YES];
263
359
  [self.commandDelegate sendPluginResult:commandResult callbackId:callBackId];
264
360
  }
265
361
  } else {
266
362
  @synchronized (self) {
267
- self.dicWakeUp = wakeMsgDic;
363
+ self.dicWakeUpDetail = dicWakeupDetail;
268
364
  }
269
365
  }
366
+
367
+
368
+
270
369
  }
271
370
 
272
371
  #pragma mark - setter and getter methods
@@ -277,9 +376,16 @@ NSString * const XinstallThirdPlatform = @"XINSTALL_THIRDPLATFORM_CORDOVA_THIRDP
277
376
  return _marrWakeUpCallbackId;
278
377
  }
279
378
 
379
+ - (NSMutableArray *)marrWakeUpDetailCallbackId {
380
+ if (_marrWakeUpDetailCallbackId == nil) {
381
+ _marrWakeUpDetailCallbackId = [[NSMutableArray alloc] init];
382
+ }
383
+ return _marrWakeUpDetailCallbackId;
384
+ }
385
+
280
386
  #pragma mark - version methods
281
387
  - (NSString *)xiSdkThirdVersion {
282
- return @"1.3.0";
388
+ return @"1.5.5";
283
389
  }
284
390
 
285
391
  - (NSInteger)xiSdkType {
@@ -18,7 +18,8 @@ typedef NS_ENUM(NSInteger, XinstallErrorType) {
18
18
  XinstallErrorTypeAppForbid, // 该 App 已被 Xinstall 后台封禁
19
19
  XinstallErrorTypePermissionDenied, // 该操作不被允许(一般代表调用的方法没有开通权限)
20
20
  XinstallErrorTypeParams, // 入参不正确
21
- XinstallErrorTypeInitSDKUnfinished // SDK 初始化未成功完成
21
+ XinstallErrorTypeInitSDKUnfinished, // SDK 初始化未成功完成
22
+ XinstallErrorTypeNotValidWakeUp // 没有通过 Xinstall Web SDK 集成的页面拉起
22
23
  };
23
24
 
24
25
  @interface XinstallError : NSObject
@@ -1,4 +1,4 @@
1
- // 1.2.9
1
+ // 1.5.5
2
2
  // XinstallSDK.h
3
3
  // XinstallSDK
4
4
  //
@@ -19,9 +19,20 @@ NS_ASSUME_NONNULL_BEGIN
19
19
  * 一键拉起时获取 H5页面 携带的动态参数,参数中如果携带渠道,也会在方法中一起返回渠道号
20
20
  * @param appData 动态参数对象
21
21
  * appData 的 uo co 数据如果前端传入不是正常的json 数据,会返回前端传入的 String ,如果为正常 JSON 数据 会返回字典或数组
22
+ * @discuss 【注意】该方法只会在成功获取到拉起参数时,才会回调。如果无法成功获取到拉起参数,则不会执行该回调方法。
22
23
  */
23
24
  - (void)xinstall_getWakeUpParams:(nullable XinstallData *)appData;
24
25
 
26
+ /**
27
+ * 一键拉起时获取 H5页面 携带的动态参数,参数中如果携带渠道,也会在方法中一起返回渠道号
28
+ * @param appData 动态参数对象
29
+ * @param error 如果没有正确处理唤醒参数,则 appData == nil 且 error != nil ;如果正确处理了唤醒参数,则 appData != nil 且 error == nil
30
+ * appData 的 uo co 数据如果前端传入不是正常的json 数据,会返回前端传入的 String ,如果为正常 JSON 数据 会返回字典或数组
31
+ * @discuss 【注意】该方法无论是否成功获取到拉起参数,均会回调。
32
+ * @discuss 【注意】如果同时实现了 「- xinstall_getWakeUpParams:」 和 「- xinstall_getWakeUpParams:error:」方法,那么只会回调「- xinstall_getWakeUpParams:error:」方法
33
+ */
34
+ - (void)xinstall_getWakeUpParams:(nullable XinstallData *)appData error:(nullable XinstallError *)error;
35
+
25
36
  /**
26
37
  * 安装时获取 H5页面 携带的动态参数,参数中如果携带渠道,也会在方法中一起返回渠道号
27
38
  * @param appData 动态参数对象
@@ -51,13 +62,38 @@ NS_ASSUME_NONNULL_BEGIN
51
62
 
52
63
  /**
53
64
  * 【重要】初始化 Xinstall SDK
54
- * 该方法只需要调用一次,调用实际尽量提前,一般在 App 启动时调用该方法进行初始化
65
+ * 该方法只需要调用一次,调用时机尽量提前,一般在 App 启动时调用该方法进行初始化
55
66
  * 调用该方法前,需在 Info.plist 文件中配置键值对,键为固定值 com.xinstall.APP_KEY ,值为 Xinstall 后台对应应用的 appKey,可在 Xinstall 官方后台获取
56
67
  *
57
68
  * @param delegate 实现 XinstallDelegate 的对象
58
69
  */
59
70
  + (void)initWithDelegate:(id<XinstallDelegate> _Nonnull)delegate;
60
71
 
72
+ /**
73
+ * 【重要】初始化 Xinstall SDK(支持广告平台渠道。若您不使用广告平台渠道,请使用 + initWithDelegate: 方法,否则可能导致上架 App Store 时被拒绝)
74
+ * 该方法只需要调用一次,调用时机尽量提前,一般在 App 启动时调用该方法进行初始化
75
+ * 调用该方法前,需在 Info.plist 文件中配置键值对,键为固定值 com.xinstall.APP_KEY ,值为 Xinstall 后台对应应用的 appKey,可在 Xinstall 官方后台获取
76
+ *
77
+ * @param delegate 实现 XinstallDelegate 的对象
78
+ * @param idfa 当前手机 IDFA 字符串
79
+ *
80
+ * @discuss [该方法和 + initWithDelegate: 的区别]:使用该方法初始化时,需要根据文档获取 IDFA 后进行初始化,支持上报广告平台渠道的数据(在 Xinstall 管理后台新建的广告平台渠道);使用 + initWithDelegate: 方法初始化,则无法统计广告平台渠道的数据。
81
+ */
82
+ + (void)initWithDelegate:(id<XinstallDelegate> _Nonnull)delegate idfa:(NSString *)idfa;
83
+
84
+ /**
85
+ * 【重要】初始化 Xinstall SDK(支持广告平台渠道。若您不使用广告平台渠道,请使用 + initWithDelegate: 方法,否则可能导致上架 App Store 时被拒绝)
86
+ * 该方法只需要调用一次,调用时机尽量提前,一般在 App 启动时调用该方法进行初始化
87
+ * 调用该方法前,需在 Info.plist 文件中配置键值对,键为固定值 com.xinstall.APP_KEY ,值为 Xinstall 后台对应应用的 appKey,可在 Xinstall 官方后台获取
88
+ *
89
+ * @param delegate 实现 XinstallDelegate 的对象
90
+ * @param idfa 当前手机 IDFA 字符串,可以为空
91
+ * @param asaToken 当前手机 ASA token,可以为空
92
+ *
93
+ * @discuss [该方法和 + initWithDelegate: 的区别]:使用该方法初始化时,需要根据文档获取 IDFA 后进行初始化,支持上报广告平台渠道的数据(在 Xinstall 管理后台新建的广告平台渠道);支持上报 ASA 渠道的数据
94
+ */
95
+ + (void)initWithDelegate:(id<XinstallDelegate> _Nonnull)delegate idfa:(nullable NSString *)idfa asaToken:(nullable NSString *)asaToken;
96
+
61
97
  /**
62
98
  * 处理 通用链接
63
99
  * @param userActivity 由 AppDelegate 和 SceneDelegate 内对应方法中传入
@@ -94,6 +130,13 @@ NS_ASSUME_NONNULL_BEGIN
94
130
  */
95
131
  - (void)reportEventPoint:(NSString *_Nonnull)eventID eventValue:(long)eventValue;
96
132
 
133
+ /**
134
+ * 上报一次分享id(建议在分享成功后上报)
135
+ *
136
+ * @param xinShareId 分享id
137
+ */
138
+ - (void)reportShareByXinShareId:(NSString *_Nonnull)xinShareId;
139
+
97
140
  + (BOOL)handleSchemeURL:(NSURL *_Nullable)URL;
98
141
 
99
142
 
Binary file
@@ -1,6 +1,51 @@
1
+ cordova.define("cordova-plugin-xinstall.xinstall", function(require, exports, module) {
1
2
  var exec = require('cordova/exec');
2
3
 
3
4
  module.exports = {
5
+
6
+ /**
7
+ * 不接入广告的初始化方法
8
+ */
9
+ init: function() {
10
+ function pass() {};
11
+ exec(pass,pass,"XinstallPlugin","initNoAd",[])
12
+ },
13
+
14
+ initWithAd: function (params,premissedBackBlock) {
15
+ function pass() {};
16
+
17
+ var adEnable = params.adEnable;
18
+ if (adEnable == null) {
19
+ adEnable = false;
20
+ }
21
+
22
+ var oaid = params.oaid;
23
+ var gaid = params.gaid;
24
+ var isPremission = params.isPremission;
25
+
26
+ if (premissedBackBlock == null) {
27
+ premissedBackBlock = pass;
28
+ }
29
+
30
+ var idfa = params.idfa;
31
+ if (idfa == null) {
32
+ idfa = "";
33
+ }
34
+ var asaEnable = params.asaEnable;
35
+ if (asaEnable == null) {
36
+ asaEnable = false;
37
+ }
38
+
39
+ exec(premissedBackBlock,pass,"XinstallPlugin","initWithAd",[adEnable,oaid,gaid,isPremission,idfa,asaEnable]);
40
+ } ,
41
+
42
+
43
+ setLog: function (isOpen) {
44
+ function pass() {};
45
+ exec(pass,pass,"XinstallPlugin","setLog",[isOpen]);
46
+ },
47
+
48
+
4
49
  /**
5
50
  * 获取安装参数
6
51
  * @param onSuccess 成功回调:数据格式为 {'channelCode': 1002, 'data': {'key': 'value'}}
@@ -17,6 +62,13 @@ module.exports = {
17
62
  exec(onSuccess, onError, "XinstallPlugin", "registerWakeUpHandler", []);
18
63
  },
19
64
 
65
+ /**
66
+ * 注册唤醒监听(会返回相关错误)
67
+ */
68
+ registerWakeUpDetailHandler: function(onSuccess, onError){
69
+ exec(onSuccess, onError, "XinstallPlugin", "registerWakeUpDetailHandler",[]);
70
+ },
71
+
20
72
  /**
21
73
  * 注册统计
22
74
  */
@@ -24,14 +76,6 @@ module.exports = {
24
76
  function pass() {};
25
77
  exec(pass, pass, "XinstallPlugin", "reportRegister", []);
26
78
  },
27
-
28
- /**
29
- * 开启应用宝功能
30
- */
31
- openYybWakeUp: function() {
32
- function pass() {};
33
- exec(pass, pass, "XinstallPlugin", "openYybWakeUp", []);
34
- }
35
79
 
36
80
  /**
37
81
  * 上报事件
@@ -41,5 +85,15 @@ module.exports = {
41
85
  reportEffectEvent: function(eventId, eventValue){
42
86
  function pass() {};
43
87
  exec(pass, pass, "XinstallPlugin", "reportEffectEvent", [eventId, eventValue]);
44
- }
45
- };
88
+ },
89
+
90
+ /**
91
+ * 分享裂变事件上报
92
+ * @param userId 用户Id
93
+ */
94
+ reportShareByXinShareId: function(userId) {
95
+ function pass() {};
96
+ exec(pass, pass, "XinstallPlugin", "reportShareByXinShareId",[userId]);
97
+ }
98
+ };
99
+ });