From b8ec3be49a2bc250b68f3970431ac802aff615b2 Mon Sep 17 00:00:00 2001 From: Salma ElTarzi Date: Tue, 18 Jul 2017 17:05:33 +0200 Subject: [PATCH 1/2] :bug: 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 --- .../RNInstabugReactnativeModule.java | 20 +++++++++++-------- index.js | 10 ++++++++++ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java index 44b8cbf40..39362a7f0 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java @@ -2,6 +2,8 @@ import android.app.Application; import android.net.Uri; +import android.os.Handler; +import android.os.Looper; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; @@ -122,12 +124,8 @@ public RNInstabugReactnativeModule(ReactApplicationContext reactContext, Applica super(reactContext); this.androidApplication = androidApplication; this.mInstabug = mInstabug; - try { - Instabug.invoke(); - Instabug.dismiss(); - } catch (Exception e) { - e.printStackTrace(); - } + //init placHolders + placeHolders = new InstabugCustomTextPlaceHolder(); } @Override @@ -152,7 +150,13 @@ public void startWithToken(String androidToken, String invocationEvent) { @ReactMethod public void invoke() { try { - mInstabug.invoke(); + Handler handler = new Handler(Looper.getMainLooper()); + handler.post(new Runnable() { + @Override + public void run() { + mInstabug.invoke(); + } + }); } catch (Exception e) { e.printStackTrace(); } @@ -1105,7 +1109,7 @@ public void run() { private InstabugCustomTextPlaceHolder.Key getStringToKeyConstant(String key) { String keyInLowerCase = key.toLowerCase(); - switch (keyInLowerCase) { + switch (key) { case SHAKE_HINT: return InstabugCustomTextPlaceHolder.Key.SHAKE_HINT; case SWIPE_HINT: diff --git a/index.js b/index.js index 16339b169..40a19e01e 100644 --- a/index.js +++ b/index.js @@ -721,6 +721,16 @@ module.exports = { Instabug.setPromptOptionsEnabled(chat, bug, feedback); }, + /** + * Enable/Disable debug logs from Instabug SDK + * Default state: disabled + * + * @param isDebugEnabled whether debug logs should be printed or not into LogCat + */ + setDebugEnabled: function(isDebugEnabled) { + Instabug.setDebugEnabled(isDebugEnabled); + }, + /** * Enables all Instabug functionality * It works on android only From f4fc9d53e13eed5d903eba86f1e6df8e1ff410b6 Mon Sep 17 00:00:00 2001 From: Salma ElTarzi Date: Tue, 18 Jul 2017 18:03:24 +0200 Subject: [PATCH 2/2] Make sure that set debug enabled is for the android platform to avoid crashes in iOS --- .../instabug/reactlibrary/RNInstabugReactnativeModule.java | 1 - index.js | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java index 39362a7f0..af6941c5c 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java @@ -1108,7 +1108,6 @@ public void run() { } private InstabugCustomTextPlaceHolder.Key getStringToKeyConstant(String key) { - String keyInLowerCase = key.toLowerCase(); switch (key) { case SHAKE_HINT: return InstabugCustomTextPlaceHolder.Key.SHAKE_HINT; diff --git a/index.js b/index.js index 40a19e01e..894bd7d77 100644 --- a/index.js +++ b/index.js @@ -728,7 +728,9 @@ module.exports = { * @param isDebugEnabled whether debug logs should be printed or not into LogCat */ setDebugEnabled: function(isDebugEnabled) { - Instabug.setDebugEnabled(isDebugEnabled); + if (Platform.OS === 'android') { + Instabug.setDebugEnabled(isDebugEnabled); + } }, /**