mirror of
https://github.com/status-im/instabug-reactnative.git
synced 2025-03-01 13:40:42 +00:00
Add startWithTokenForAndroid to index.js
This commit is contained in:
parent
eb6401cac5
commit
3ccbfdf60a
@ -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
|
||||
*
|
||||
|
@ -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<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
|
||||
List<NativeModule> modules = new ArrayList<>();
|
||||
modules.add(new RNInstabugReactnativeModule(reactContext, this.mInstagbug));
|
||||
modules.add(new RNInstabugReactnativeModule(reactContext));
|
||||
return modules;
|
||||
}
|
||||
|
||||
|
34
index.js
34
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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user