Skip to content

Commit b8ec3be

Browse files
committed
🐛 Fix the bug where the sdk gets invoked automatically at app launch, and need to press twice on a button to manually invoke the sdk, fix a bug where changing the value of the strings did not work correctly
1 parent 8d9db72 commit b8ec3be

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import android.app.Application;
44
import android.net.Uri;
5+
import android.os.Handler;
6+
import android.os.Looper;
57

68
import com.facebook.react.bridge.ReactApplicationContext;
79
import com.facebook.react.bridge.ReactContextBaseJavaModule;
@@ -122,12 +124,8 @@ public RNInstabugReactnativeModule(ReactApplicationContext reactContext, Applica
122124
super(reactContext);
123125
this.androidApplication = androidApplication;
124126
this.mInstabug = mInstabug;
125-
try {
126-
Instabug.invoke();
127-
Instabug.dismiss();
128-
} catch (Exception e) {
129-
e.printStackTrace();
130-
}
127+
//init placHolders
128+
placeHolders = new InstabugCustomTextPlaceHolder();
131129
}
132130

133131
@Override
@@ -152,7 +150,13 @@ public void startWithToken(String androidToken, String invocationEvent) {
152150
@ReactMethod
153151
public void invoke() {
154152
try {
155-
mInstabug.invoke();
153+
Handler handler = new Handler(Looper.getMainLooper());
154+
handler.post(new Runnable() {
155+
@Override
156+
public void run() {
157+
mInstabug.invoke();
158+
}
159+
});
156160
} catch (Exception e) {
157161
e.printStackTrace();
158162
}
@@ -1105,7 +1109,7 @@ public void run() {
11051109

11061110
private InstabugCustomTextPlaceHolder.Key getStringToKeyConstant(String key) {
11071111
String keyInLowerCase = key.toLowerCase();
1108-
switch (keyInLowerCase) {
1112+
switch (key) {
11091113
case SHAKE_HINT:
11101114
return InstabugCustomTextPlaceHolder.Key.SHAKE_HINT;
11111115
case SWIPE_HINT:

index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,16 @@ module.exports = {
721721
Instabug.setPromptOptionsEnabled(chat, bug, feedback);
722722
},
723723

724+
/**
725+
* Enable/Disable debug logs from Instabug SDK
726+
* Default state: disabled
727+
*
728+
* @param isDebugEnabled whether debug logs should be printed or not into LogCat
729+
*/
730+
setDebugEnabled: function(isDebugEnabled) {
731+
Instabug.setDebugEnabled(isDebugEnabled);
732+
},
733+
724734
/**
725735
* Enables all Instabug functionality
726736
* It works on android only

0 commit comments

Comments
 (0)