Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 322e4e8

Browse files
Fix startWithToken API
1 parent d1d58bd commit 322e4e8

File tree

3 files changed

+18
-54
lines changed

3 files changed

+18
-54
lines changed

android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
import com.instabug.library.invocation.InstabugInvocationMode;
1515
import com.instabug.library.invocation.util.InstabugFloatingButtonEdge;
1616
import java.util.Locale;
17+
import java.util.HashMap;
1718
import android.net.Uri;
19+
import java.util.Map;
1820

1921

2022
public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
@@ -31,7 +33,7 @@ public RNInstabugReactnativeModule(ReactApplicationContext reactContext, Applica
3133

3234
@Override
3335
public String getName() {
34-
return "RNInstabugReactnative";
36+
return "Instabug";
3537
}
3638

3739
/**
@@ -40,15 +42,15 @@ public String getName() {
4042
* @param androidApplicationToken
4143
*/
4244
@ReactMethod
43-
public void startInstabugWithTokenForAndroid(String androidApplicationToken)
45+
public void startWithToken(String androidApplicationToken,InstabugInvocationEvent invocationEvent)
4446
{
4547
this.mAndroidApplicationToken = androidApplicationToken;
4648

4749
mInstabug = new Instabug.Builder(androidApplication, mAndroidApplicationToken)
4850
.setEmailFieldRequired(false)
4951
.setFloatingButtonOffsetFromTop(400)
5052
.setTheme(InstabugColorTheme.InstabugColorThemeLight)
51-
.setInvocationEvent(InstabugInvocationEvent.FLOATING_BUTTON)
53+
.setInvocationEvent(invocationEvent)
5254
.setIntroMessageEnabled(false)
5355
.build();
5456
}
@@ -188,4 +190,16 @@ public void showIntroMessage() {
188190
e.printStackTrace();
189191
}
190192
}
193+
194+
@Override
195+
public Map<String, Object> getConstants() {
196+
final Map<String, Object> constants = new HashMap<>();
197+
constants.put("invocationEventFloatingButton", InstabugInvocationEvent.FLOATING_BUTTON);
198+
constants.put("invocationEventTwoFingersSwipeLeft", InstabugInvocationEvent.TWO_FINGER_SWIPE_LEFTt);
199+
constants.put("invocationEventScreenshot", InstabugInvocationEvent.SCREENSHOT_GESTURE);
200+
constants.put("invocationEventShake", InstabugInvocationEvent.SHAKE);
201+
constants.put("invocationEventNone", InstabugInvocationEvent.NONE);
202+
203+
return constants;
204+
}
191205
}

android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativePackage.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,5 @@ public List<Class<? extends JavaScriptModule>> createJSModules() {
3838
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
3939
return Collections.emptyList();
4040
}
41+
4142
}

index.js

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,7 @@ import { NativeModules, NativeAppEventEmitter, Platform } from 'react-native';
99
let {Instabug} = NativeModules;
1010

1111
module.exports = {
12-
/**
13-
* Starts the SDK.
14-
* This is the main SDK method that does all the magic. This is the only
15-
* method that SHOULD be called.
16-
* Should be called in constructor of the app registery component
17-
* @param {string} Token The token that identifies the app, you can find
18-
* it on your dashboard.
19-
*/
20-
startWithToken: function(token) {
21-
if( Platform.OS === 'ios') {
22-
Instabug.startWithToken(iosToken, Instabug.constants.invocationEvent.floatingButton);
23-
24-
} else {
2512

26-
Instabug.startInstabugWithTokenForAndroid(androidToken);
27-
28-
}
29-
30-
31-
},
3213
/**
3314
* Starts the SDK.
3415
* This is the main SDK method that does all the magic. This is the only
@@ -40,39 +21,7 @@ module.exports = {
4021
* the SDK's UI.
4122
*/
4223
startWithToken: function(token, invocationEvent) {
43-
if( Platform.OS === 'ios') {
4424
Instabug.startWithToken(token, invocationEvent);
45-
46-
} else {
47-
Instabug.startInstabugWithTokenForAndroid(token);
48-
49-
}
50-
51-
52-
},
53-
/**
54-
* Starts the SDK.
55-
* This is the main SDK method that does all the magic. This is the only
56-
* method that SHOULD be called.
57-
* Should be called in constructor of the app registery component
58-
* @param {string} androidToken The token that identifies the app, you can find
59-
* it on your dashboard.
60-
* @param {string} iosToken The token that identifies the app, you can find
61-
* it on your dashboard.
62-
* @param {constants.invocationEvent} invocationEvent The event that invokes
63-
* the SDK's UI.
64-
*/
65-
startWithToken: function(androidToken,iosToken, invocationEvent) {
66-
if( Platform.OS === 'ios') {
67-
Instabug.startWithToken(iosToken, invocationEvent);
68-
69-
} else {
70-
71-
Instabug.startInstabugWithTokenForAndroid(androidToken);
72-
73-
}
74-
75-
7625
},
7726

7827
/**

0 commit comments

Comments
 (0)