Skip to content

Commit 2652577

Browse files
committed
Android 返回 shouldRetry
1 parent e00d8e7 commit 2652577

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ swift代码:
184184

185185
示例:
186186
``` dart
187-
Future wakeupHandler(Map<String, dynamic> data) async {
187+
Future wakeupHandler(Map<String, Object> data) async {
188188
setState(() {
189189
debugLog = "wakeup result : channel=" +
190190
data['channelCode'] +
@@ -203,7 +203,7 @@ _openinstallFlutterPlugin.init(wakeupHandler);
203203
示例:
204204
``` dart
205205
206-
Future installHandler(Map<String, dynamic> data) async {
206+
Future installHandler(Map<String, Object> data) async {
207207
setState(() {
208208
debugLog = "install result : channel=" +
209209
data['channelCode'] +

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

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -120,21 +120,23 @@ public void onMethodCall(MethodCall call, @NonNull final Result result) {
120120
OpenInstall.getInstall(new AppInstallListener() {
121121
@Override
122122
public void onInstallFinish(AppData appData, Error error) {
123-
Map<String, String> data = data2Map(appData);
123+
Map<String, Object> data = data2Map(appData);
124124
boolean shouldRetry = error!=null && error.shouldRetry();
125-
data.put("shouldRetry", String.valueOf(shouldRetry));
126-
channel.invokeMethod(METHOD_INSTALL_NOTIFICATION,data );
125+
data.put("shouldRetry", shouldRetry);
126+
if(error != null) {
127+
data.put("message", error.getErrorMsg());
128+
}
129+
channel.invokeMethod(METHOD_INSTALL_NOTIFICATION, data);
127130
}
128131
}, seconds == null ? 0 : seconds);
129132
result.success("OK");
130133
} else if (METHOD_INSTALL_RETRY.equalsIgnoreCase(call.method)) {
131134
Integer seconds = call.argument("seconds");
132135
OpenInstall.getInstallCanRetry(new AppInstallRetryAdapter() {
133136
@Override
134-
public void onInstall(AppData appData, boolean retry) {
135-
Map<String, String> data = data2Map(appData);
136-
data.put("retry", String.valueOf(retry));
137-
data.put("shouldRetry", String.valueOf(retry)); // 以后保存统一
137+
public void onInstall(AppData appData, boolean shouldRetry) {
138+
Map<String, Object> data = data2Map(appData);
139+
data.put("shouldRetry", shouldRetry); // 以后保存统一
138140
channel.invokeMethod(METHOD_INSTALL_NOTIFICATION, data);
139141
}
140142
}, seconds == null ? 0 : seconds);
@@ -156,17 +158,17 @@ public void onInstall(AppData appData, boolean retry) {
156158
} else if (METHOD_SHARE.equalsIgnoreCase(call.method)) {
157159
String shareCode = call.argument("shareCode");
158160
String sharePlatform = call.argument("platform");
159-
final Map<String, String> data = new HashMap<>();
161+
final Map<String, Object> data = new HashMap<>();
160162
if(TextUtils.isEmpty(shareCode) || TextUtils.isEmpty(sharePlatform)){
161163
data.put("message", "shareCode or platform is empty");
162-
data.put("shouldRetry", String.valueOf(false));
164+
data.put("shouldRetry", false);
163165
result.success(data);
164166
}else {
165167
OpenInstall.reportShare(shareCode, sharePlatform, new ResultCallback<Void>() {
166168
@Override
167169
public void onResult(@Nullable Void v, @Nullable Error error) {
168170
boolean shouldRetry = error!=null && error.shouldRetry();
169-
data.put("shouldRetry", String.valueOf(shouldRetry));
171+
data.put("shouldRetry", shouldRetry);
170172
if(error != null) {
171173
data.put("message", error.getErrorMsg());
172174
}
@@ -318,8 +320,8 @@ public boolean onRequestPermissionsResult(int requestCode, String[] permissions,
318320
}
319321
};
320322

321-
private static Map<String, String> data2Map(AppData data) {
322-
Map<String, String> result = new HashMap<>();
323+
private static Map<String, Object> data2Map(AppData data) {
324+
Map<String, Object> result = new HashMap<>();
323325
if (data != null) {
324326
result.put("channelCode", data.getChannel());
325327
result.put("bindData", data.getData());

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-github\\\\openinstall_flutter_plugin\\\\","dependencies":[]}],"android":[{"name":"openinstall_flutter_plugin","path":"D:\\\\workspace\\\\op-github\\\\openinstall_flutter_plugin\\\\","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"openinstall_flutter_plugin","dependencies":[]}],"date_created":"2023-04-11 16:28:16.921725","version":"2.8.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-github\\\\openinstall_flutter_plugin\\\\","dependencies":[]}],"android":[{"name":"openinstall_flutter_plugin","path":"D:\\\\workspace\\\\op-github\\\\openinstall_flutter_plugin\\\\","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"openinstall_flutter_plugin","dependencies":[]}],"date_created":"2023-04-13 13:02:05.597240","version":"2.8.1"}

0 commit comments

Comments
 (0)