From 2545f7f8a4654667dff5c1920c82a5a5425f7b8a Mon Sep 17 00:00:00 2001 From: DevHossamHassan Date: Thu, 22 Jun 2017 06:27:45 +0200 Subject: [PATCH] Enable `setPostInvocationHandler` API for android --- .../RNInstabugReactnativeModule.java | 26 +++++++++++++++++++ index.js | 5 ++-- 2 files changed, 29 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 6e5fc5f..2423e40 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java @@ -23,6 +23,8 @@ import com.instabug.library.logging.InstabugLog; import com.instabug.library.bugreporting.model.ReportCategory; import com.instabug.library.InstabugCustomTextPlaceHolder; import com.instabug.library.user.UserEventParam; +import com.instabug.library.OnSdkDismissedCallback; +import com.instabug.library.bugreporting.model.Bug; import com.instabug.reactlibrary.utils.ArrayUtil; import com.instabug.reactlibrary.utils.MapUtil; @@ -925,6 +927,30 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { } } + /** + * Sets a block of code to be executed right after the SDK's UI is dismissed. + * This block is executed on the UI thread. Could be used for performing any + * UI changes after the SDK's UI is dismissed. + * + * @param {postInvocationHandler} postInvocationHandler - A callback to get executed after + * dismissing the SDK. + */ + @ReactMethod + public void setPostInvocationHandler(final Callback postInvocationHandler) { + try { + + mInstabug.setOnSdkDismissedCallback(new OnSdkDismissedCallback() { + @Override + public void onSdkDismissed(DismissType issueState, Bug.Type bugType) { + postInvocationHandler.invoke(); + } + }); + + } catch (java.lang.Exception exception) { + exception.printStackTrace(); + } + } + private InstabugCustomTextPlaceHolder.Key getStringToKeyConstant(String key) { String keyInLowerCase = key.toLowerCase(); switch (keyInLowerCase) { diff --git a/index.js b/index.js index a4abcec..7da2718 100644 --- a/index.js +++ b/index.js @@ -150,9 +150,10 @@ module.exports = { postInvocationHandler(payload['dismissType'], payload['reportType']); } ); - - Instabug.setPostInvocationHandler(postInvocationHandler); } + + Instabug.setPostInvocationHandler(postInvocationHandler); + }, /**