diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java index 9016fa5..70eae20 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java @@ -5,7 +5,8 @@ import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.Callback; - +import com.instabug.library.InstabugColorTheme; +import com.instabug.library.InstabugInvocationEvent; import com.instabug.library.InstabugInvocationMode; import com.instabug.library.Instabug; @@ -16,10 +17,13 @@ import android.net.Uri; public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { private Instabug mInstabug; + private String mAndroidApplicationToken; + private Instabug.Builder mBuilder; + private Application mApplication; - public RNInstabugReactnativeModule(ReactApplicationContext reactContext, Instabug instabug) { + public RNInstabugReactnativeModule(ReactApplicationContext reactContext) { super(reactContext); - this.mInstabug = instabug; + this.mApplication = reactContext; } @Override @@ -27,6 +31,26 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { return "RNInstabugReactnative"; } + /** + * start Instabug with default opetions + * default Invocation event Floating button + * @param androidApplicationToken + */ + @ReactMethod + public void startInstabugWithTokenForAndroid(String androidApplicationToken) + { + this.mAndroidApplicationToken = androidApplicationToken; + + mInstagbug = new Instabug.Builder(mApplication, mAndroidApplicationToken) + .setDebugEnabled(true) + .setEmailFieldRequired(false) + .setFloatingButtonOffsetFromTop(400) + .setColorTheme(InstabugColorTheme.InstabugColorThemeLight) + .setInvocationEvent(InstabugInvocationEvent.InstabugInvocationEventFloatingButton) + .setShouldShowIntroDialog(false) + .build(); + } + /** * Adds tag(s) to issues before sending them * diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativePackage.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativePackage.java index 4dac266..df454b3 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativePackage.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativePackage.java @@ -19,39 +19,10 @@ import com.instabug.library.Instabug; public class RNInstabugReactnativePackage implements ReactPackage { - private String mToken; - private Application mApplication; - - private Instabug mInstagbug; - private Instabug.Builder mBuilder; - - public RNInstabugReactnativePackage(Instabug instabug) { - this.mInstagbug = instabug; - } - - public RNInstabugReactnativePackage(Instabug.Builder builder) { - this.mBuilder = builder; - } - - public RNInstabugReactnativePackage(String token, Application application) { - this.mToken = token; - this.mApplication = application; - - mInstagbug = new Instabug.Builder(mApplication, mToken) - .setDebugEnabled(true) - .setEmailFieldRequired(false) - .setFloatingButtonOffsetFromTop(400) - .setColorTheme(InstabugColorTheme.InstabugColorThemeDark) - .setInvocationEvent(InstabugInvocationEvent.InstabugInvocationEventFloatingButton) - .setShouldShowIntroDialog(false) - //.setInvocationEvent(InstabugInvocationEvent.InstabugInvocationEventShake) - .build(); - - } @Override public List createNativeModules(ReactApplicationContext reactContext) { List modules = new ArrayList<>(); - modules.add(new RNInstabugReactnativeModule(reactContext, this.mInstagbug)); + modules.add(new RNInstabugReactnativeModule(reactContext)); return modules; } diff --git a/index.js b/index.js index 1041cfa..53a30cc 100644 --- a/index.js +++ b/index.js @@ -9,6 +9,30 @@ import { NativeModules, NativeAppEventEmitter } 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} 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); + + } + + + }, /** * Starts the SDK. * This is the main SDK method that does all the magic. This is the only @@ -20,7 +44,15 @@ module.exports = { * the SDK's UI. */ startWithToken: function(token, invocationEvent) { - Instabug.startWithToken(token, invocationEvent); + if( Platform.OS === 'ios') { + Instabug.startWithToken(token, invocationEvent); + + } else { + Instabug.startInstabugWithTokenForAndroid(token); + + } + + }, /**