From a957991779a85c33bd0321e393dd23253cee0521 Mon Sep 17 00:00:00 2001 From: Salma Ali Date: Thu, 7 Mar 2019 16:26:22 +0200 Subject: [PATCH 1/2] :handshake: Fix/8.1.1 (#42) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🐛 fix all setState APIs crashing by moving them to run on the main thread * ⬆️ Update native Android SDK to version 8.1.2 --- android/build.gradle | 2 +- .../RNInstabugReactnativeModule.java | 84 +++++++++++++------ 2 files changed, 60 insertions(+), 26 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 5c059dda6..3f44882a9 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -25,7 +25,7 @@ android { dependencies { implementation 'com.facebook.react:react-native:+' - api ('com.instabug.library:instabug:8.1.1'){ + api ('com.instabug.library:instabug:8.1.2'){ exclude group: 'com.android.support:appcompat-v7' } } diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java index 2c3d34903..2727cf324 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java @@ -32,6 +32,7 @@ import com.instabug.featuresrequest.ActionType; import com.instabug.library.Feature; import com.instabug.library.Instabug; +import com.instabug.library.InstabugState; import com.instabug.library.OnSdkDismissCallback; import com.instabug.library.extendedbugreport.ExtendedBugReport; import com.instabug.library.internal.module.InstabugLocale; @@ -471,9 +472,9 @@ public void sendHandledJSCrash(String exceptionObject) { public void setCrashReportingEnabled(boolean isEnabled) { try { if (isEnabled) { - Instabug.setCrashReportingState(Feature.State.ENABLED); + CrashReporting.setState(Feature.State.ENABLED); } else { - Instabug.setCrashReportingState(Feature.State.DISABLED); + CrashReporting.setState(Feature.State.DISABLED); } } catch (Exception e) { e.printStackTrace(); @@ -608,11 +609,16 @@ public boolean isEnabled() { */ @ReactMethod public void enable() { - try { - mInstabug.enable(); - } catch (Exception e) { - e.printStackTrace(); - } + new Handler(Looper.getMainLooper()).post(new Runnable() { + @Override + public void run() { + try { + Instabug.setState(InstabugState.ENABLED); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); } /** @@ -1584,12 +1590,22 @@ public void setReportTypes(ReadableArray types) { } @ReactMethod - public void setBugReportingEnabled(boolean isEnabled) { - if (isEnabled) { - BugReporting.setState(Feature.State.ENABLED); - } else { - BugReporting.setState(Feature.State.DISABLED); - } + public void setBugReportingEnabled(final boolean isEnabled) { + new Handler(Looper.getMainLooper()).post(new Runnable() { + @Override + public void run() { + try { + if (isEnabled) { + BugReporting.setState(Feature.State.ENABLED); + } else { + BugReporting.setState(Feature.State.DISABLED); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } @ReactMethod @@ -1607,12 +1623,21 @@ public void showBugReportingWithReportTypeAndOptions(String reportType, Readable } @ReactMethod - public void setChatsEnabled(boolean isEnabled) { - if (isEnabled) { - Chats.setState(Feature.State.ENABLED); - } else { - Chats.setState(Feature.State.DISABLED); - } + public void setChatsEnabled(final boolean isEnabled) { + new Handler(Looper.getMainLooper()).post(new Runnable() { + @Override + public void run() { + try { + if (isEnabled) { + Chats.setState(Feature.State.ENABLED); + } else { + Chats.setState(Feature.State.DISABLED); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + }); } @ReactMethod @@ -1621,12 +1646,21 @@ public void showChats() { } @ReactMethod - public void setRepliesEnabled(boolean isEnabled) { - if (isEnabled) { - Replies.setState(Feature.State.ENABLED); - } else { - Replies.setState(Feature.State.DISABLED); - } + public void setRepliesEnabled(final boolean isEnabled) { + new Handler(Looper.getMainLooper()).post(new Runnable() { + @Override + public void run() { + try { + if (isEnabled) { + Replies.setState(Feature.State.ENABLED); + } else { + Replies.setState(Feature.State.DISABLED); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + }); } @ReactMethod From 4731fdf0bb79746826fe27a015c7868b94db375d Mon Sep 17 00:00:00 2001 From: Salma Ali Date: Wed, 13 Mar 2019 16:44:16 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=90=9B=20fix=20CrashReporting=20modul?= =?UTF-8?q?e=20not=20added=20to=20the=20main=20module=20(#43)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 2 ++ modules/CrashReporting.js | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 214cd2715..6f4dd251b 100644 --- a/index.js +++ b/index.js @@ -11,6 +11,7 @@ import Surveys from './modules/Surveys'; import FeatureRequests from './modules/FeatureRequests'; import Chats from './modules/Chats'; import Replies from './modules/Replies'; +import CrashReporting from './modules/CrashReporting'; InstabugUtils.captureJsErrors(); @@ -979,5 +980,6 @@ InstabugModule.Surveys = Surveys; InstabugModule.FeatureRequests = FeatureRequests; InstabugModule.Chats = Chats; InstabugModule.Replies = Replies; +InstabugModule.CrashReporting = CrashReporting; module.exports = InstabugModule; diff --git a/modules/CrashReporting.js b/modules/CrashReporting.js index 8580b050a..f224291fd 100644 --- a/modules/CrashReporting.js +++ b/modules/CrashReporting.js @@ -1,4 +1,4 @@ -import { NativeModules } from 'react-native'; +import { NativeModules, Platform } from 'react-native'; import InstabugUtils from '../utils/InstabugUtils'; let { Instabug } = NativeModules;