Skip to content

Commit f3800dc

Browse files
author
WuWenhui
committed
android升级到2.5.4
1 parent 5a48044 commit f3800dc

File tree

11 files changed

+135
-85
lines changed

11 files changed

+135
-85
lines changed

.idea/workspace.xml

Lines changed: 22 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 57 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
# openinstall flutter plugin
22

3+
4+
openinstall模块封装了openinstall平台原生SDK,集成了**渠道统计,携带参数安装,快速安装与一键跳转**功能,目前渠道支持**H5渠道****广告平台渠道**以及**Apple Search Ads (ASA) 渠道**
5+
使用openinstall模块可实现以下多种场景:
6+
![实现场景](https://res.cdn.openinstall.io/doc/scene.jpg)
7+
38
## 一、配置
4-
请先从 [openinstall平台](https://developer.openinstall.io/) 申请开发者账号并创建应用,获取 `AppKey``scheme`
9+
前往 [openinstall控制台](https://developer.openinstall.io/) 创建应用并获取 openinstall 为应用分配的` appkey``scheme` 以及 iOS的关联域名(Associated Domains)
10+
![appkey和scheme](https://res.cdn.openinstall.io/doc/ios-appkey.png)
511

612
### Android 平台配置
713

8-
#### 配置appkey
9-
`/android/app/build.gradle` 中添加下列代码
10-
``` gradle
14+
#### 配置 appkey
15+
`/android/app/build.gradle` 中添加代码设置appkey
16+
``` groovy
1117
android: {
1218
....
1319
defaultConfig {
@@ -20,7 +26,7 @@ android: {
2026
```
2127

2228
#### 配置 scheme
23-
修改 `/android/app/src/main/AndroidMenifest.xml` 文件,`activity` 标签内添加 `intent-filter` (一般为 `MainActivity`)
29+
修改 `/android/app/src/main/AndroidMenifest.xml` 文件,在跳转 `Activity` 标签内添加 `intent-filter`
2430
``` xml
2531
<intent-filter>
2632
<action android:name="android.intent.action.VIEW"/>
@@ -31,23 +37,28 @@ android: {
3137
<data android:scheme="openinstall为应用分配的scheme"/>
3238
</intent-filter>
3339
```
40+
如果跳转与启动页面是同一 `Activity` ,则配置示例如图:
41+
![flutter-android-manifest.jpg](https://res.cdn.openinstall.io/doc/flutter-android-manifest.jpg)
3442

3543
### iOS 平台配置
36-
#### 配置APP_KEY
44+
#### 配置 appkey
3745
在Flutter工程下的 `ios/Runner/Info.plist` 文件中配置 `appKey` 键值对,如下:
3846
``` xml
3947
<key>com.openinstall.APP_KEY</key>
4048
<string>openinstall 分配给应用的 appkey</string>
4149
```
42-
#### 以下为 一键拉起 功能相关配置和代码
50+
#### 一键跳转配置
4351

4452
##### universal links 相关配置
4553

46-
* 开启Associated Domains服务
54+
1. 开启Associated Domains服务
55+
56+
对于iOS,为确保能正常跳转,AppID必须开启Associated Domains功能,请到[苹果开发者网站](https://developer.apple.com/ "苹果开发者网站"),选择Certificate, Identifiers & Profiles,选择相应的AppID,开启Associated Domains。
57+
> 注意:当AppID重新编辑过之后,需要更新相应的mobileprovision证书。
4758
48-
对于iOS,为确保能正常跳转,AppID必须开启Associated Domains功能,请到[苹果开发者网站](https://developer.apple.com/ "苹果开发者网站"),选择Certificate, Identifiers & Profiles,选择相应的AppID,开启Associated Domains。注意:当AppID重新编辑过之后,需要更新相应的mobileprovision证书。(图文配置步骤请看[Flutter接入指南](https://www.openinstall.io/doc/flutter_sdk.html "iOS集成指南"))。
59+
![开启Associated Domains](https://res.cdn.openinstall.io/doc/ios-ulink-1.png)
4960

50-
* 配置universal links关联域名(iOS 9以后推荐使用)
61+
2. 配置universal links关联域名(iOS 9以后推荐使用)
5162

5263
关联域名(Associated Domains) 的值请在openinstall控制台获取(openinstall应用控制台->iOS集成->iOS应用配置)
5364

@@ -178,10 +189,10 @@ swift代码:
178189

179190
## 二、使用
180191

181-
#### 初始化
192+
### 初始化
182193
`init(EventHandler wakeupHandler)`
183194

184-
初始化时,需要传入**拉起回调**获取 web 端传过来的动态参数
195+
初始化时,需要传入**拉起回调** 获取 web 端传过来的动态参数
185196

186197
示例:
187198
``` dart
@@ -196,7 +207,7 @@ Future wakeupHandler(Map<String, dynamic> data) async {
196207
197208
_openinstallFlutterPlugin.init(wakeupHandler);
198209
```
199-
#### 获取安装参数
210+
### 获取安装参数
200211
`install(EventHandler installHandler, [int seconds = 10])`
201212

202213
在 APP 需要安装参数时(由 web 网页中传递过来的,如邀请码、游戏房间号等动态参数),调用此接口,在回调中获取参数
@@ -228,56 +239,63 @@ _openinstallFlutterPlugin.reportRegister();
228239
#### 效果点统计
229240
`reportEffectPoint(String pointId, int pointValue)`
230241

231-
效果点建立在渠道基础之上,主要用来统计终端用户对某些特殊业务的使用效果。调用此接口时,请使用后台创建的 “效果点ID” 作为pointId
242+
效果点建立在渠道基础之上,主要用来统计终端用户对某些特殊业务的使用效果。调用此接口时,请使用后台创建的 “效果点ID” 作为 pointId
232243

233244
示例:
234245
``` dart
235246
_openinstallFlutterPlugin.reportEffectPoint("effect_test", 1);
236247
```
237248

238249
## 三、导出apk/ipa包并上传
239-
- 代码集成完毕后,需要导出安装包上传openinstall后台,openinstall会自动完成所有的应用配置工作。
240-
- 上传完成后即可开始在线模拟测试,体验完整的App安装/拉起流程;待测试无误后,再完善下载配置信息。
250+
251+
集成完毕后,通过云编译导出iOS/Android安装包上传[openinstall控制台](https://developer.openinstall.io/),openinstal会检查应用的集成配置
252+
![上传ipa安装包](https://res.cdn.openinstall.io/doc/upload-ipa-jump.png)
253+
254+
255+
上传完成后即可开始在线模拟测试,体验完整的App安装/跳转流程
256+
![在线测试](https://res.cdn.openinstall.io/doc/js-test.png)
241257

242258

243259
---
244260

245261
## 广告接入补充文档
246262

247263
### Android平台
248-
#### 广告平台配置
249-
针对广告平台接入,新增配置接口,在调用 `init` 之前调用。参考 [广告平台对接Android集成指引](https://www.openinstall.io/doc/ad_android.html)
250-
``` js
251-
/**
252-
* adEnabled 为 true 表示 openinstall 需要获取广告追踪相关参数,默认为 false
253-
* oaid 为 null 时,表示交由 openinstall 获取 oaid, 默认为 null
254-
* gaid 为 null 时,表示交由 openinstall 获取 gaid, 默认为 null
255-
*/
256-
_openinstallFlutterPlugin.config(true, "通过移动安全联盟获取到的 oaid", "通过 google api 获取到的 advertisingId");
264+
1、针对广告平台接入,新增配置接口,在调用 `init` 之前调用。参考 [广告平台对接Android集成指引](https://www.openinstall.io/doc/ad_android.html)
265+
``` dart
266+
var adConfig = new Map();
267+
adConfig["adEnabled"] = true;
268+
_openinstallFlutterPlugin.configAndroid(adConfig);
257269
```
258-
例如: 开发者自己获取到了 oaid,但是需要 openinstall 获取 gaid,则调用代码为
259-
``` js
260-
// f32a09dc-3312-d43e-6583-62fac13f33ae 是通过移动安全联盟获取到的 oaid
261-
_openinstallFlutterPlugin.config(true, "f32a09dc-3312-d43e-6583-62fac13f33ae", null);
270+
> **注意:** `_openinstallFlutterPlugin.config(adEnabled, oaid, gaid)` 接口已废弃,请使用新的配置接口
271+
272+
可选参数说明:
273+
274+
| 参数名| 参数类型 | 描述 |
275+
| --- | --- | --- |
276+
| adEnabled| bool | 是否需要 SDK 获取广告追踪相关参数 |
277+
| macDisabled | bool | 是否禁止 SDK 获取 mac 地址 |
278+
| imeiDisabled | bool | 是否禁止 SDK 获取 imei |
279+
| gaid | string | 通过 google api 获取到的 advertisingId,SDK 将不再获取gaid |
280+
| oaid | string | 通过移动安全联盟获取到的 oaid,SDK 将不再获取oaid |
281+
282+
2、针对广告平台,为了精准地匹配到渠道,需要获取设备唯一标识码(IMEI),因此需要在 AndroidManifest.xml 中添加权限声明
283+
262284
```
263-
#### 设备唯一标识码获取
264-
针对广告平台,为了精准地匹配到渠道,需要获取设备唯一标识码(IMEI),因此需要做额外的权限申请。
265-
1、声明权限
266-
`AndroidMainfest.xml` 配置文件中添加了需要申请的权限 `<uses-permission android:name="android.permission.READ_PHONE_STATE"/>`
267-
268-
2、申请权限并初始化
269-
可使用插件提供的 api 进行权限申请,调用初始化 api,第二个参数 `permission=true` 表示插件进行权限申请
270-
``` dart
271-
_openinstallFlutterPlugin.init(wakeupHandler, true);
285+
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
272286
```
273-
也可在 `Flutter` 自行进行权限申请,只需要确保在初始化之前申请权限,例如
287+
288+
3、在权限申请成功后,再进行openinstall初始化。**无论终端用户是否同意,都要调用初始化**
289+
代码示例如下:
274290
``` dart
275291
// 使用 permission_handler
276292
if (await Permission.phone.request().isGranted) {
277293
// 获取到了权限
278294
}
279295
_openinstallFlutterPlugin.init(wakeupHandler);
280296
```
297+
> 注意:`_openinstallFlutterPlugin.init(wakeupHandler, permission);` 接口已废弃,请自行处理权限请求
298+
281299

282300
### iOS平台
283301

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ android {
3434
}
3535

3636
dependencies {
37-
implementation files('libs/OpenInstall_v2.5.3.jar')
37+
implementation fileTree(dir: 'libs', include: ['*.jar'])
3838
}

android/libs/OpenInstall_v2.5.3.jar

-84.4 KB
Binary file not shown.

android/libs/OpenInstall_v2.5.4.jar

86 KB
Binary file not shown.

android/src/main/java/io/openinstall/openinstall_flutter_plugin/OpeninstallFlutterPlugin.java

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ public void onMethodCall(MethodCall call, @NonNull Result result) {
7171
String oaid = call.argument("oaid");
7272
String gaid = call.argument("gaid");
7373
Boolean adEnabled = call.argument("adEnabled");
74-
config(adEnabled == null ? false : adEnabled, oaid, gaid);
74+
Boolean macDisabled = call.argument("macDisabled");
75+
Boolean imeiDisabled = call.argument("imeiDisabled");
76+
config(adEnabled, oaid, gaid, macDisabled, imeiDisabled);
7577
result.success("OK");
7678
} else if (METHOD_INIT.equalsIgnoreCase(call.method)) {
7779
init();
@@ -109,14 +111,28 @@ public void onInstall(AppData appData) {
109111
}
110112
}
111113

112-
private void config(boolean adEnabled, String oaid, String gaid) {
114+
private void config(Boolean adEnabled, String oaid, String gaid,
115+
Boolean macDisabled, Boolean imeiDisabled) {
113116
Configuration.Builder builder = new Configuration.Builder();
114-
builder.adEnabled(adEnabled);
117+
builder.adEnabled(checkBoolean(adEnabled));
115118
builder.oaid(oaid);
116119
builder.gaid(gaid);
117-
Log.d(TAG, String.format("config adEnabled=%b, oaid=%s, gaid=%s",
118-
adEnabled, oaid == null ? "NULL" : oaid, gaid == null ? "NULL" : gaid));
120+
if (checkBoolean(macDisabled)) {
121+
builder.macDisabled();
122+
}
123+
if (checkBoolean(imeiDisabled)) {
124+
builder.imeiDisabled();
125+
}
119126
configuration = builder.build();
127+
Log.d(TAG, String.format("Configuration: adEnabled=%s, oaid=%s, gaid=%s, macDisabled=%s, imeiDisabled=%s",
128+
configuration.isAdEnabled(), configuration.getOaid(), configuration.getGaid(),
129+
configuration.isMacDisabled(), configuration.isImeiDisabled()));
130+
131+
}
132+
133+
private boolean checkBoolean(Boolean bool) {
134+
if (bool == null) return false;
135+
return bool;
120136
}
121137

122138
private void init() {

example/.flutter-plugins-dependencies

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"openinstall_flutter_plugin","path":"D:\\\\workspace\\\\OP\\\\openinstall_flutter_plugin\\\\","dependencies":[]}],"android":[{"name":"openinstall_flutter_plugin","path":"D:\\\\workspace\\\\OP\\\\openinstall_flutter_plugin\\\\","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"openinstall_flutter_plugin","dependencies":[]}],"date_created":"2021-05-20 15:24:30.066461","version":"2.0.5"}
1+
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"openinstall_flutter_plugin","path":"D:\\\\workspace\\\\OP\\\\openinstall_flutter_plugin\\\\","dependencies":[]}],"android":[{"name":"openinstall_flutter_plugin","path":"D:\\\\workspace\\\\OP\\\\openinstall_flutter_plugin\\\\","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"openinstall_flutter_plugin","dependencies":[]}],"date_created":"2021-08-23 14:37:43.036878","version":"2.0.5"}

example/android/app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,6 @@
1818
android:launchMode="singleTop"
1919
android:theme="@style/LaunchTheme"
2020
android:windowSoftInputMode="adjustResize">
21-
<!-- This keeps the window background of the activity showing
22-
until Flutter renders its first frame. It can be removed if
23-
there is no splash screen (such as the default splash screen
24-
defined in @style/LaunchTheme). -->
25-
<!--<meta-data
26-
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
27-
android:value="true"/>-->
28-
2921
<intent-filter>
3022
<action android:name="android.intent.action.MAIN"/>
3123
<category android:name="android.intent.category.LAUNCHER"/>

example/android/app/src/main/res/drawable/launch_background.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!-- Modify this file to customize your launch splash screen -->
33
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
4-
<item android:drawable="@android:color/white" />
4+
<item android:drawable="@android:color/holo_red_light" />
55

66
<!-- You can insert your own image assets here -->
77
<!-- <item>

0 commit comments

Comments
 (0)