From b8ec3be49a2bc250b68f3970431ac802aff615b2 Mon Sep 17 00:00:00 2001 From: Salma ElTarzi Date: Tue, 18 Jul 2017 17:05:33 +0200 Subject: [PATCH] :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 44b8cbf..39362a7 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 @@ package com.instabug.reactlibrary; 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 class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { 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 class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { @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 class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { 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 16339b1..40a19e0 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