Skip to content

Commit 057c5b1

Browse files
committed
✨ Add api method for setIntroMessageEnabled for android
1 parent acfd914 commit 057c5b1

File tree

2 files changed

+53
-2
lines changed

2 files changed

+53
-2
lines changed

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

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
5454
private final String INVOCATION_MODE_NEW_FEEDBACK = "feedback";
5555
private final String INVOCATION_MODE_NEW_CHAT = "chat";
5656
private final String INVOCATION_MODE_CHATS_LIST = "chats";
57+
//FloatingButtonEdge
58+
private final String FLOATING_BUTTON_EDGE_RIGHT = "right";
59+
private final String FLOATING_BUTTON_EDGE_LEFT = "left";
5760
//locales
5861
private final String LOCALE_ARABIC = "arabic";
5962
private final String LOCALE_CHINESE_SIMPLIFIED = "chinesesimplified";
@@ -526,6 +529,38 @@ private InstabugInvocationEvent getInvocationEventById(String invocationEventVal
526529
}
527530
}
528531

532+
/**
533+
* Sets the default edge at which the floating button will be shown
534+
*
535+
* @param instabugFloatingButtonEdge edge to stick Floating button to
536+
* @see InstabugFloatingButtonEdge
537+
*/
538+
539+
@ReactMethod
540+
public void setFloatingButtonEdge(String floatingButtonEdgeValue) {
541+
try {
542+
mInstabug.setFloatingButtonEdge(getFloatingButtonEdge(floatingButtonEdgeValue));
543+
} catch (Exception e) {
544+
e.printStackTrace();
545+
}
546+
}
547+
548+
private InstabugFloatingButtonEdge getFloatingButtonEdge(String floatingButtonEdgeValue) {
549+
InstabugFloatingButtonEdge floatingButtonEdge = InstabugFloatingButtonEdge.RIGHT;
550+
try {
551+
if (floatingButtonEdgeValue.equals(FLOATING_BUTTON_EDGE_LEFT)) {
552+
floatingButtonEdge = InstabugFloatingButtonEdge.LEFT;
553+
} else if (floatingButtonEdgeValue.equals(FLOATING_BUTTON_EDGE_RIGHT)) {
554+
floatingButtonEdge = InstabugFloatingButtonEdge.RIGHT;
555+
}
556+
557+
return invocationEvent;
558+
} catch (Exception e) {
559+
e.printStackTrace();
560+
return invocationEvent;
561+
}
562+
}
563+
529564
/**
530565
* Enabled/disable chat notification
531566
*
@@ -991,6 +1026,20 @@ public void setSurveysEnabled(boolean surveysEnabled) {
9911026
}
9921027
}
9931028

1029+
/**
1030+
* Sets the default value of the intro message guide that gets shown on launching the app
1031+
*
1032+
* @param enabled true to show intro message guide
1033+
*/
1034+
@ReactMethod
1035+
public void setIntroMessageEnabled(boolean enabled) {
1036+
try {
1037+
mInstabug.setIntroMessageEnabled(enabled);
1038+
} catch (Exception e) {
1039+
e.printStackTrace();
1040+
}
1041+
}
1042+
9941043

9951044
/**
9961045
* Sets the runnable that gets executed just before showing any valid survey<br/>
@@ -1232,6 +1281,9 @@ public Map<String, Object> getConstants() {
12321281
constants.put("invocationModeNewChat", INVOCATION_MODE_NEW_CHAT);
12331282
constants.put("invocationModeChatsList", INVOCATION_MODE_CHATS_LIST);
12341283

1284+
constants.put("floatingButtonEdgeLeft",FLOATING_BUTTON_EDGE_LEFT);
1285+
constants.put("floatingButtonEdgeRight",FLOATING_BUTTON_EDGE_RIGHT);
1286+
12351287
constants.put("localeArabic", LOCALE_ARABIC);
12361288
constants.put("localeChineseSimplified", LOCALE_CHINESE_SIMPLIFIED);
12371289
constants.put("localeChineseTraditional", LOCALE_CHINESE_TRADITIONAL);

index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,7 @@ module.exports = {
296296
* intro message is enabled or not.
297297
*/
298298
setIntroMessageEnabled: function (isIntroMessageEnabled) {
299-
if (Platform.OS === 'ios')
300-
Instabug.setIntroMessageEnabled(isIntroMessageEnabled);
299+
Instabug.setIntroMessageEnabled(isIntroMessageEnabled);
301300
},
302301

303302
/**

0 commit comments

Comments
 (0)