Skip to content

Commit f082e99

Browse files
a7medevHeshamMegid
authored andcommitted
[INSD-9704] Fix The onInvoke Callback (#369)
1 parent 970c787 commit f082e99

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## [Unreleased](https://github.com/Instabug/Instabug-Flutter/compare/v11.12.0...dev)
4+
5+
### Fixed
6+
7+
- Fix an issue with the `onInvoke` callback not being called and causing `Instabug.show` to break on Android ([#369](https://github.com/Instabug/Instabug-Flutter/pull/369)).
8+
39
## [11.12.0](https://github.com/Instabug/Instabug-Flutter/compare/v11.10.1...v11.12.0) (May 30, 2023)
410

511
### Changed

android/src/main/java/com/instabug/flutter/modules/BugReportingApi.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.instabug.bug.BugReporting;
99
import com.instabug.flutter.generated.BugReportingPigeon;
1010
import com.instabug.flutter.util.ArgsRegistry;
11+
import com.instabug.flutter.util.ThreadManager;
1112
import com.instabug.library.Feature;
1213
import com.instabug.library.OnSdkDismissCallback;
1314
import com.instabug.library.extendedbugreport.ExtendedBugReport;
@@ -132,9 +133,17 @@ public void bindOnInvokeCallback() {
132133
BugReporting.setOnInvokeCallback(new OnInvokeCallback() {
133134
@Override
134135
public void onInvoke() {
135-
flutterApi.onSdkInvoke(new BugReportingPigeon.BugReportingFlutterApi.Reply<Void>() {
136+
// The on invoke callback for Flutter needs to be run on the
137+
// main thread, otherwise, it won't work and will break the
138+
// Instabug.show API
139+
ThreadManager.runOnMainThread(new Runnable() {
136140
@Override
137-
public void reply(Void reply) {
141+
public void run() {
142+
flutterApi.onSdkInvoke(new BugReportingPigeon.BugReportingFlutterApi.Reply<Void>() {
143+
@Override
144+
public void reply(Void reply) {
145+
}
146+
});
138147
}
139148
});
140149
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
package com.instabug.flutter.util;
22

33
import android.os.AsyncTask;
4+
import android.os.Handler;
5+
import android.os.Looper;
46

57
public class ThreadManager {
68
// TODO: migrate to Flutter's TaskQueue
79
public static void runOnBackground(Runnable runnable) {
810
AsyncTask.execute(runnable);
911
}
12+
13+
public static void runOnMainThread(Runnable runnable) {
14+
new Handler(Looper.getMainLooper()).post(runnable);
15+
}
1016
}

0 commit comments

Comments
 (0)