Fix startWithToken API

This commit is contained in:
DevHossamHassan
2016-10-20 16:24:17 +02:00
parent d1d58bd7c5
commit 322e4e8eb2
3 changed files with 18 additions and 54 deletions
@@ -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<String, Object> getConstants() {
final Map<String, Object> 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;
}
}
@@ -38,4 +38,5 @@ public class RNInstabugReactnativePackage implements ReactPackage {
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
return Collections.emptyList();
}
}
-51
View File
@@ -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);
}
},
/**