From 322e4e8eb2c5d60578fa4c155b7dc41df0071766 Mon Sep 17 00:00:00 2001 From: DevHossamHassan Date: Thu, 20 Oct 2016 16:24:17 +0200 Subject: [PATCH] Fix startWithToken API --- .../RNInstabugReactnativeModule.java | 20 ++++++-- .../RNInstabugReactnativePackage.java | 1 + index.js | 51 ------------------- 3 files changed, 18 insertions(+), 54 deletions(-) diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java index fdfdb8f..f6903fe 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java @@ -14,7 +14,9 @@ import com.instabug.library.invocation.InstabugInvocationEvent; import com.instabug.library.invocation.InstabugInvocationMode; import com.instabug.library.invocation.util.InstabugFloatingButtonEdge; import java.util.Locale; +import java.util.HashMap; import android.net.Uri; +import java.util.Map; public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { @@ -31,7 +33,7 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { @Override public String getName() { - return "RNInstabugReactnative"; + return "Instabug"; } /** @@ -40,7 +42,7 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { * @param androidApplicationToken */ @ReactMethod - public void startInstabugWithTokenForAndroid(String androidApplicationToken) + public void startWithToken(String androidApplicationToken,InstabugInvocationEvent invocationEvent) { this.mAndroidApplicationToken = androidApplicationToken; @@ -48,7 +50,7 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { .setEmailFieldRequired(false) .setFloatingButtonOffsetFromTop(400) .setTheme(InstabugColorTheme.InstabugColorThemeLight) - .setInvocationEvent(InstabugInvocationEvent.FLOATING_BUTTON) + .setInvocationEvent(invocationEvent) .setIntroMessageEnabled(false) .build(); } @@ -188,4 +190,16 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { e.printStackTrace(); } } + + @Override + public Map getConstants() { + final Map constants = new HashMap<>(); + constants.put("invocationEventFloatingButton", InstabugInvocationEvent.FLOATING_BUTTON); + constants.put("invocationEventTwoFingersSwipeLeft", InstabugInvocationEvent.TWO_FINGER_SWIPE_LEFTt); + constants.put("invocationEventScreenshot", InstabugInvocationEvent.SCREENSHOT_GESTURE); + constants.put("invocationEventShake", InstabugInvocationEvent.SHAKE); + constants.put("invocationEventNone", InstabugInvocationEvent.NONE); + + return constants; + } } \ No newline at end of file diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativePackage.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativePackage.java index 68d8421..77e9c7a 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativePackage.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativePackage.java @@ -38,4 +38,5 @@ public class RNInstabugReactnativePackage implements ReactPackage { public List createViewManagers(ReactApplicationContext reactContext) { return Collections.emptyList(); } + } \ No newline at end of file diff --git a/index.js b/index.js index 51a9d21..23d64c0 100644 --- a/index.js +++ b/index.js @@ -9,26 +9,7 @@ import { NativeModules, NativeAppEventEmitter, Platform } from 'react-native'; let {Instabug} = NativeModules; module.exports = { - /** - * Starts the SDK. - * This is the main SDK method that does all the magic. This is the only - * method that SHOULD be called. - * Should be called in constructor of the app registery component - * @param {string} Token The token that identifies the app, you can find - * it on your dashboard. - */ - startWithToken: function(token) { - if( Platform.OS === 'ios') { - Instabug.startWithToken(iosToken, Instabug.constants.invocationEvent.floatingButton); - } else { - - Instabug.startInstabugWithTokenForAndroid(androidToken); - - } - - - }, /** * Starts the SDK. * This is the main SDK method that does all the magic. This is the only @@ -40,39 +21,7 @@ module.exports = { * the SDK's UI. */ startWithToken: function(token, invocationEvent) { - if( Platform.OS === 'ios') { Instabug.startWithToken(token, invocationEvent); - - } else { - Instabug.startInstabugWithTokenForAndroid(token); - - } - - - }, - /** - * Starts the SDK. - * This is the main SDK method that does all the magic. This is the only - * method that SHOULD be called. - * Should be called in constructor of the app registery component - * @param {string} androidToken The token that identifies the app, you can find - * it on your dashboard. - * @param {string} iosToken The token that identifies the app, you can find - * it on your dashboard. - * @param {constants.invocationEvent} invocationEvent The event that invokes - * the SDK's UI. - */ - startWithToken: function(androidToken,iosToken, invocationEvent) { - if( Platform.OS === 'ios') { - Instabug.startWithToken(iosToken, invocationEvent); - - } else { - - Instabug.startInstabugWithTokenForAndroid(androidToken); - - } - - }, /**