Skip to content

Commit 35aed6e

Browse files
Merge pull request #49 from Instabug/SALMAT/testRelease
🐛 Fix the bug where the sdk gets invoked automatically at app lau…
2 parents eac7935 + f4fc9d5 commit 35aed6e

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

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

Lines changed: 12 additions & 9 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
}
@@ -1104,8 +1108,7 @@ public void run() {
11041108
}
11051109

11061110
private InstabugCustomTextPlaceHolder.Key getStringToKeyConstant(String key) {
1107-
String keyInLowerCase = key.toLowerCase();
1108-
switch (keyInLowerCase) {
1111+
switch (key) {
11091112
case SHAKE_HINT:
11101113
return InstabugCustomTextPlaceHolder.Key.SHAKE_HINT;
11111114
case SWIPE_HINT:

index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,18 @@ 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+
if (Platform.OS === 'android') {
732+
Instabug.setDebugEnabled(isDebugEnabled);
733+
}
734+
},
735+
724736
/**
725737
* Enables all Instabug functionality
726738
* It works on android only

0 commit comments

Comments
 (0)