opoinstall-cordova-plugin 0.0.0-stage → 1.0.0

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.
Files changed (27) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +260 -2
  3. package/package.json +22 -4
  4. package/plugin.xml +101 -0
  5. package/src/android/OpoInstallPlugin.java +327 -0
  6. package/src/android/lib/OpoInstall_v2.1.0.jar +0 -0
  7. package/src/ios/AppDelegate+OpoInstallSDK.m +50 -0
  8. package/src/ios/CDVOpoInstall.h +24 -0
  9. package/src/ios/CDVOpoInstall.m +245 -0
  10. package/src/ios/CDVOpoInstallStorage.h +22 -0
  11. package/src/ios/CDVOpoInstallStorage.m +25 -0
  12. package/src/ios/libs/OpoInstallData.h +33 -0
  13. package/src/ios/libs/OpoInstallSDK.h +171 -0
  14. package/src/ios/libs/OpoInstallSDK.xcframework/Info.plist +48 -0
  15. package/src/ios/libs/OpoInstallSDK.xcframework/ios-arm64/Headers/OpoInstallData.h +33 -0
  16. package/src/ios/libs/OpoInstallSDK.xcframework/ios-arm64/Headers/OpoInstallSDK.h +171 -0
  17. package/src/ios/libs/OpoInstallSDK.xcframework/ios-arm64/Headers/OpoInstallSharePlatform.h +148 -0
  18. package/src/ios/libs/OpoInstallSDK.xcframework/ios-arm64/Headers/PrivacyInfo.xcprivacy +81 -0
  19. package/src/ios/libs/OpoInstallSDK.xcframework/ios-arm64/libOpoInstallSDK.a +0 -0
  20. package/src/ios/libs/OpoInstallSDK.xcframework/ios-arm64_x86_64-simulator/Headers/OpoInstallData.h +33 -0
  21. package/src/ios/libs/OpoInstallSDK.xcframework/ios-arm64_x86_64-simulator/Headers/OpoInstallSDK.h +171 -0
  22. package/src/ios/libs/OpoInstallSDK.xcframework/ios-arm64_x86_64-simulator/Headers/OpoInstallSharePlatform.h +148 -0
  23. package/src/ios/libs/OpoInstallSDK.xcframework/ios-arm64_x86_64-simulator/Headers/PrivacyInfo.xcprivacy +81 -0
  24. package/src/ios/libs/OpoInstallSDK.xcframework/ios-arm64_x86_64-simulator/libOpoInstallSDK.a +0 -0
  25. package/src/ios/libs/OpoInstallSharePlatform.h +148 -0
  26. package/src/ios/libs/PrivacyInfo.xcprivacy +81 -0
  27. package/www/opoinstall-cordova-plugin.js +85 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Opoinstall
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,261 @@
1
- # Temporary Holding Version
1
+ # opoinstall-cordova-plugin
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ opoinstall 的 cordova 插件
4
+
5
+ 文档最后提供了在 capacitor 中使用需要做的配置
6
+
7
+ ## 一、安装插件
8
+
9
+ 前往 [opoinstall 官网](https://www.opoinstall.com/),注册账户,登录管理控制台,创建应用后,跳过 "集成指引",在 "应用集成" 的对应平台的 "应用配置" 中获取 `appkey` 和 `scheme` 以及 iOS 的关联域名。
10
+
11
+ ![获取appkey和scheme](https://web.cdn.opoinstallcloud.com/doc/ios-appkey.png)
12
+
13
+ 使用下列命令安装并配置 opoinstall 插件
14
+
15
+ ```
16
+ cordova plugin add opoinstall-cordova-plugin --variable OPOINSTALL_APPKEY=appkey --variable OPOINSTALL_SCHEME=scheme
17
+ ```
18
+
19
+ *如配置错误,可先卸载再重新安装插件*
20
+
21
+ ```
22
+ cordova plugin rm opoinstall-cordova-plugin --variable OPOINSTALL_APPKEY=appkey --variable OPOINSTALL_SCHEME=scheme
23
+ ```
24
+
25
+ ## 二、调用API
26
+
27
+ ### 1 初始化
28
+
29
+ App 启动时,请确保用户同意《隐私政策》之后,再调用初始化;如果用户不同意,则不进行 opoinstall SDK 初始化。参考 [应用合规指南](https://www.opoinstall.com/docs)
30
+
31
+ ```js
32
+ window.opoinstall.init();
33
+ ```
34
+
35
+ ### 2 快速安装和一键拉起
36
+
37
+ #### 拉起参数获取
38
+
39
+ 调用以下代码注册拉起回调,应尽早调用。如在 `deviceready` 事件回调之时注册
40
+
41
+ ```js
42
+ window.opoinstall.registerWakeUpHandler(function(data){
43
+ console.log("opoinstall.wakeup success : " + JSON.stringify(data));
44
+ }, function(msg){
45
+ console.log("opoinstall.wakeup error : " + msg)
46
+ });
47
+ ```
48
+
49
+ 成功回调的data数据格式
50
+
51
+ ```json
52
+ {"channel": "渠道号", "data": {"自定义key": "自定义value"}}
53
+ ```
54
+
55
+ 对于 iOS,为确保能正常跳转,AppID 必须开启 Associated Domains 功能,请到[苹果开发者网站](https://developer.apple.com),选择 Certificate, Identifiers & Profiles,选择相应的 AppID,开启 Associated Domains。注意:当 AppID 重新编辑过之后,需要更新相应的 mobileprovision 证书。
56
+
57
+ ![associatedDev](https://web.cdn.opoinstallcloud.com/doc/assciationDev.png)
58
+
59
+ 在 Xcode 中配置 opoinstall 为当前应用生成的关联域名(Associated Domains)。
60
+
61
+ ![添加associatedDomains](https://web.cdn.opoinstallcloud.com/doc/ios-associated-domains.png)
62
+
63
+ ### 3 携带参数安装 (高级版功能)
64
+
65
+ #### 获取安装参数
66
+
67
+ ```js
68
+ window.opoinstall.getInstall(function(data){
69
+ console.log('opoinstall.getInstall success: ' + JSON.stringify(data));
70
+ }, function(msg){
71
+ console.log('opoinstall.getInstall error: ' + msg);
72
+ });
73
+ ```
74
+
75
+ 也可传入一个整形数值,单位秒,指定时间未返回将超时
76
+
77
+ ```js
78
+ window.opoinstall.getInstall(function(data){
79
+ console.log('opoinstall.getInstall success: ' + JSON.stringify(data));
80
+ }, function(msg){
81
+ console.log('opoinstall.getInstall error: ' + msg);
82
+ }, 10);
83
+ ```
84
+
85
+ 成功回调的data数据格式
86
+
87
+ ```json
88
+ {"channel": "渠道号", "data": {"自定义key": "自定义value"}}
89
+ ```
90
+
91
+ Android 平台还可调用 `getInstallCanRetry`,成功回调中会额外返回 `retry` 字段,表示是否可在合适时机重试。(已废弃,建议直接使用 `getInstall`)
92
+
93
+ ```js
94
+ window.opoinstall.getInstallCanRetry(function(data){
95
+ console.log('opoinstall.getInstallCanRetry success: ' + JSON.stringify(data));
96
+ }, function(msg){
97
+ console.log('opoinstall.getInstallCanRetry error: ' + msg);
98
+ }, 3);
99
+ ```
100
+
101
+ ### 4 渠道统计 (高级版功能)
102
+
103
+ SDK 会自动完成访问量、点击量、安装量、活跃量、留存率等统计工作。其它业务相关统计由开发人员使用 api 上报
104
+
105
+ #### 4.1 注册量统计
106
+
107
+ 根据自身的业务规则,在确保用户完成 app 注册的情况下调用 api
108
+
109
+ ```js
110
+ window.opoinstall.reportRegister();
111
+ ```
112
+
113
+ #### 4.2 渠道效果统计
114
+
115
+ 统计终端用户对某些特殊业务的使用效果,如充值金额,分享次数等等。\
116
+ 请在 [opoinstall 控制台](https://developer.opoinstall.com/) 的 “效果点管理” 中添加对应的效果点\
117
+ 调用接口进行效果点的上报,第一个参数对应控制台中的 **效果点ID**
118
+
119
+ ```js
120
+ window.opoinstall.reportEffectPoint("effect_test", 1);
121
+ ```
122
+
123
+ #### 4.3 效果点明细统计
124
+
125
+ 效果点建立在渠道基础之上,主要用来统计终端用户对某些特殊业务的使用效果。调用此接口时,请使用后台创建的 “效果点ID” 作为 pointId
126
+
127
+ ```js
128
+ var extras = {
129
+ "key1": "value1",
130
+ "key2": "value2"
131
+ }
132
+ window.opoinstall.reportEffectPoint("effect_detail", 1, extras);
133
+ ```
134
+
135
+ ### 5 分享统计
136
+
137
+ ```js
138
+ window.opoinstall.reportShare(function(data){
139
+ console.log('opoinstall.reportShare success: ' + JSON.stringify(data));
140
+ }, function(msg){
141
+ console.log('opoinstall.reportShare error: ' + msg);
142
+ }, "shareCode", "WechatSession");
143
+ ```
144
+
145
+ ## 三、导出apk/ipa包并上传
146
+
147
+ 代码集成完毕后,需要导出安装包上传 opoinstall 后台,opoinstall 会自动完成所有的应用配置工作。
148
+ ![上传安装包](https://web.cdn.opoinstallcloud.com/doc/upload-ipa-jump.png)
149
+
150
+ 上传完成后即可开始在线模拟测试,体验完整的App安装/拉起流程;待测试无误后,再完善下载配置信息。
151
+ ![在线测试](https://web.cdn.opoinstallcloud.com/doc/js-test.png)
152
+
153
+ ## 如有疑问
154
+
155
+ 若您在集成或使用中有任何疑问或者困难,请 [联系 opoinstall 客服](https://www.opoinstall.com/)。
156
+
157
+ ***
158
+
159
+ ## 初始化前配置
160
+
161
+ ### Android平台
162
+
163
+ 在调用 init 之前调用,用于设置设备信息相关配置
164
+
165
+ ```js
166
+ var options = {
167
+ androidId: "传入设备的 android_id,SDK 将不再获取",
168
+ simulatorDisabled: true
169
+ }
170
+ window.opoinstall.configAndroid(options);
171
+ ```
172
+
173
+ options 可选参数如下:
174
+
175
+ | 参数名 | 参数类型 | 描述 |
176
+ | ----------------- | ------ | ---------------------------------------- |
177
+ | androidId | string | 传入设备的 android\_id,SDK 将不再获取;传入空字符串表示不再获取 |
178
+ | simulatorDisabled | bool | 是否禁止 SDK 检测模拟器 |
179
+
180
+ > 说明:新版本 SDK 已不再读取 imei、mac 地址、oaid、gaid、serialNumber 等设备信息,`adEnabled`、`imei`、`macAddress`、`oaid`、`gaid` 等旧参数会被忽略。
181
+
182
+ > 隐私清单:插件 `src/ios/libs/PrivacyInfo.xcprivacy` 提供了 SDK 的隐私声明内容,如工程已有 `PrivacyInfo.xcprivacy`,请将内容合并到已有文件,不要重复添加同名文件(会导致 iOS 构建冲突)。
183
+
184
+ ## 如何在 capacitor 中使用?
185
+
186
+ #### 1.安装插件
187
+
188
+ ```js
189
+ npm install opoinstall-cordova-plugin
190
+ ```
191
+
192
+ #### 2.同步到原生平台
193
+
194
+ ```js
195
+ npx cap sync
196
+ ```
197
+
198
+ #### 3.手动修改:
199
+
200
+ **Android平台**
201
+
202
+ 1)修改 capacitor-cordova-android-plugins module 下的 AndroidManifest.xml 文件,将
203
+
204
+ ```xml
205
+ <meta-data
206
+ android:name="com.opoinstall.APP_KEY"
207
+ android:value="$OPOINSTALL_APPKEY"/>
208
+ ```
209
+
210
+ 中的 `$OPOINSTALL_APPKEY` 修改为 opoinstall 为应用分配的 appkey
211
+
212
+ 2)修改 app module 下的 `AndroidManifest.xml` 文件,将
213
+
214
+ ```xml
215
+ <intent-filter>
216
+ <action android:name="android.intent.action.VIEW" />
217
+ <category android:name="android.intent.category.DEFAULT" />
218
+ <category android:name="android.intent.category.BROWSABLE" />
219
+ <data android:scheme="@string/custom_url_scheme" />
220
+ </intent-filter>
221
+ ```
222
+
223
+ 的 `@string/custom_url_scheme` 修改为 opoinstall 为应用分配的 scheme 或者新增配置
224
+
225
+ ```xml
226
+ <intent-filter>
227
+ <action android:name="android.intent.action.VIEW" />
228
+ <category android:name="android.intent.category.DEFAULT" />
229
+ <category android:name="android.intent.category.BROWSABLE" />
230
+ <data android:scheme="opoinstall为应用分配的scheme" />
231
+ </intent-filter>
232
+ ```
233
+
234
+ **iOS平台**
235
+
236
+ 不要同时使用 Cordova 模式和 Pod 模式安装插件或 SDK,会报错,最好使用 Cordova 模式安装插件,Pod 模式安装的是原生 SDK。
237
+
238
+ 1)找到 `Info.plist` 文件,添加appkey
239
+
240
+ ```xml
241
+ <key>com.opoinstall.APP_KEY</key>
242
+ <string>“从 opoinstall 官网后台获取应用的appkey”</string>
243
+ ```
244
+
245
+ 2)找到 `Info.plist` 文件,添加scheme
246
+
247
+ ```xml
248
+ <key>CFBundleURLTypes</key>
249
+ <array>
250
+ <dict>
251
+ <key>CFBundleTypeRole</key>
252
+ <string>Editor</string>
253
+ <key>CFBundleURLName</key>
254
+ <string>opoinstall</string>
255
+ <key>CFBundleURLSchemes</key>
256
+ <array>
257
+ <string>"从 opoinstall 官网后台获取应用的scheme"</string>
258
+ </array>
259
+ </dict>
260
+ </array>
261
+ ```
package/package.json CHANGED
@@ -1,6 +1,24 @@
1
1
  {
2
2
  "name": "opoinstall-cordova-plugin",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "cordova": {
5
+ "id": "opoinstall-cordova-plugin",
6
+ "platforms": [
7
+ "ios",
8
+ "android"
9
+ ]
10
+ },
11
+ "keywords": [
12
+ "一键拉起",
13
+ "免填邀请码",
14
+ "广告效果监测",
15
+ "渠道统计"
16
+ ],
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "https://github.com/OpoInstall/cordova-plugin-opoinstall.git"
20
+ },
21
+ "author": "opoinstall",
22
+ "license": "MIT",
23
+ "description": "opoinstall的cordova插件"
24
+ }
package/plugin.xml ADDED
@@ -0,0 +1,101 @@
1
+ <?xml version='1.0' encoding='utf-8'?>
2
+ <plugin id="opoinstall-cordova-plugin" version="1.0.0"
3
+ xmlns="http://apache.org/cordova/ns/plugins/1.0"
4
+ xmlns:android="http://schemas.android.com/apk/res/android">
5
+
6
+ <name>opoinstall</name>
7
+
8
+ <preference name="OPOINSTALL_APPKEY"/>
9
+ <preference name="OPOINSTALL_SCHEME"/>
10
+
11
+ <!-- android -->
12
+ <platform name="android">
13
+
14
+ <js-module name="opoinstall" src="www/opoinstall-cordova-plugin.js">
15
+ <clobbers target="opoinstall" />
16
+ </js-module>
17
+
18
+ <config-file target="res/xml/config.xml" parent="/*">
19
+ <feature name="OpoInstallPlugin">
20
+ <param name="android-package" value="io.opoinstall.cordova.OpoInstallPlugin"/>
21
+ <param name="onload" value="true" />
22
+ </feature>
23
+ </config-file>
24
+
25
+ <config-file target="AndroidManifest.xml" parent="/*">
26
+ <uses-permission android:name="android.permission.INTERNET"/>
27
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
28
+ <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
29
+ </config-file>
30
+
31
+ <config-file target="AndroidManifest.xml" parent="/manifest/application">
32
+ <meta-data
33
+ android:name="com.opoinstall.APP_KEY"
34
+ android:value="$OPOINSTALL_APPKEY"/>
35
+ </config-file>
36
+
37
+ <config-file target="AndroidManifest.xml" parent="/manifest/application/activity[@android:name='MainActivity']">
38
+ <intent-filter>
39
+ <action android:name="android.intent.action.VIEW" />
40
+ <category android:name="android.intent.category.DEFAULT" />
41
+ <category android:name="android.intent.category.BROWSABLE" />
42
+ <data android:scheme="$OPOINSTALL_SCHEME" />
43
+ </intent-filter>
44
+ </config-file>
45
+
46
+ <edit-config file="AndroidManifest.xml" target="/manifest/application/activity[@android:name='MainActivity']" mode="merge">
47
+ <activity android:launchMode="singleTask"/>
48
+ </edit-config>
49
+
50
+ <source-file src="src/android/OpoInstallPlugin.java" target-dir="src/io/opoinstall/cordova" />
51
+ <lib-file src="src/android/lib/OpoInstall_v2.1.0.jar" target-dir="libs" />
52
+
53
+ </platform>
54
+
55
+ <!-- ios -->
56
+ <platform name="ios">
57
+
58
+ <js-module name="opoinstall" src="www/opoinstall-cordova-plugin.js">
59
+ <clobbers target="opoinstall" />
60
+ </js-module>
61
+
62
+ <config-file target="config.xml" parent="/*">
63
+ <feature name="OpoInstallPlugin">
64
+ <param name="ios-package" value="CDVOpoInstall"/>
65
+ <param name="onload" value="true" />
66
+ </feature>
67
+ </config-file>
68
+
69
+ <!-- appkey 由 SDK 从 Info.plist 读取 -->
70
+ <config-file target="*-Info.plist" parent="com.opoinstall.APP_KEY">
71
+ <string>$OPOINSTALL_APPKEY</string>
72
+ </config-file>
73
+
74
+ <!-- 注册 scheme,用于一键拉起 -->
75
+ <config-file target="*-Info.plist" parent="CFBundleURLTypes">
76
+ <array>
77
+ <dict>
78
+ <key>CFBundleURLSchemes</key>
79
+ <array>
80
+ <string>$OPOINSTALL_SCHEME</string>
81
+ </array>
82
+ </dict>
83
+ </array>
84
+ </config-file>
85
+
86
+ <!-- Plugin source code -->
87
+ <header-file src="src/ios/CDVOpoInstall.h" />
88
+ <source-file src="src/ios/CDVOpoInstall.m" />
89
+ <source-file src="src/ios/AppDelegate+OpoInstallSDK.m" />
90
+ <header-file src="src/ios/CDVOpoInstallStorage.h" />
91
+ <source-file src="src/ios/CDVOpoInstallStorage.m" />
92
+ <header-file src="src/ios/libs/OpoInstallSDK.h" />
93
+ <header-file src="src/ios/libs/OpoInstallData.h" />
94
+ <header-file src="src/ios/libs/OpoInstallSharePlatform.h" />
95
+ <framework src="src/ios/libs/OpoInstallSDK.xcframework" custom="true" />
96
+
97
+ <framework src="Security.framework" />
98
+ <framework src="SystemConfiguration.framework" />
99
+
100
+ </platform>
101
+ </plugin>