diff --git a/InstabugSample/index.android.js b/InstabugSample/index.android.js index 917f43b..e940985 100644 --- a/InstabugSample/index.android.js +++ b/InstabugSample/index.android.js @@ -27,6 +27,9 @@ export default class InstabugSample extends Component { super(props); Instabug.startWithToken('0f0dc916bd9175e3b5d2fdf0cfa49a69', Instabug.invocationEvent.floatingButton); + Instabug.setPreInvocationHandler(() => { + Alert.alert("PreInvocationEvent", "Done :) "); + }); const ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2}); this.state = { dataSource: ds.cloneWithRows(this._genRows({})), diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java index 7bae1aa..75661fb 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java @@ -24,6 +24,9 @@ import com.instabug.library.bugreporting.model.ReportCategory; import com.instabug.library.InstabugCustomTextPlaceHolder; import com.instabug.library.user.UserEventParam; +import com.instabug.reactlibrary.utils.ArrayUtil; +import com.instabug.reactlibrary.utils.MapUtil; + import java.util.ArrayList; import java.util.HashMap; import java.util.Locale; @@ -875,7 +878,28 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { } } - + /** + * Sets a block of code to be executed just before the SDK's UI is presented. + * This block is executed on the UI thread. Could be used for performing any + * UI changes before the SDK's UI is shown. + * + * @param {preInvocationHandler} preInvocationHandler - A callback that gets executed before + * invoking the SDK + */ + @ReactMethod + public void setPreInvocationHandler(final Callback preInvocationHandler) { + try { + Runnable preInvocationRunnable = new Runnable() { + @Override + public void run() { + preInvocationHandler.invoke(); + } + }; + mInstabug.setPreInvocation(preInvocationRunnable); + } catch (java.lang.Exception exception) { + exception.printStackTrace(); + } + } private InstabugCustomTextPlaceHolder.Key getStringToKeyConstant(String key) { String keyInLowerCase = key.toLowerCase(); diff --git a/index.js b/index.js index 9c676fc..0b25927 100644 --- a/index.js +++ b/index.js @@ -126,9 +126,10 @@ module.exports = { 'IBGpreInvocationHandler', preInvocationHandler ); - - Instabug.setPreInvocationHandler(preInvocationHandler); } + + Instabug.setPreInvocationHandler(preInvocationHandler); + }, /**