Skip to content

Commit 07197fe

Browse files
committed
✨ showWelcomeMessage API
1 parent 1958d1c commit 07197fe

File tree

4 files changed

+72
-2
lines changed

4 files changed

+72
-2
lines changed

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
106106
private final String ENABLED = "enabled";
107107
private final String DISABLED = "disabled";
108108

109+
//Instabug welcome message modes
110+
private final String WELCOME_MESSAGE_MODE_LIVE = "welcomeMessageModeLive";
111+
private final String WELCOME_MESSAGE_MODE_BETA = "welcomeMessageModeBeta";
112+
private final String WELCOME_MESSAGE_MODE_DISABLED = "welcomeMessageModeDisabled";
113+
109114
//Theme colors
110115
private final String COLOR_THEME_LIGHT = "light";
111116
private final String COLOR_THEME_DARK = "dark";
@@ -1360,6 +1365,31 @@ public void setReproStepsMode(String reproStepsMode) {
13601365
}
13611366
}
13621367

1368+
/**
1369+
* Shows the welcome message in a specific mode.
1370+
*
1371+
* @param welcomeMessageMode An enum to set the welcome message mode to
1372+
* live, beta or disabled.
1373+
*/
1374+
@ReactMethod
1375+
public void showWelcomeMessageWithMode(String welcomeMessageMode) {
1376+
try {
1377+
switch (welcomeMessageMode) {
1378+
case WELCOME_MESSAGE_MODE_LIVE:
1379+
Instabug.showWelcomeMessage(WelcomeMessage.State.LIVE);
1380+
break;
1381+
case WELCOME_MESSAGE_MODE_BETA:
1382+
Instabug.showWelcomeMessage(WelcomeMessage.State.BETA);
1383+
break;
1384+
default:
1385+
Instabug.showWelcomeMessage(WelcomeMessage.State.LIVE);
1386+
}
1387+
1388+
} catch (Exception e) {
1389+
e.printStackTrace();
1390+
}
1391+
}
1392+
13631393
/**
13641394
* Sets the threshold value of the shake gesture for android devices.
13651395
* Default for android is an integer value equals 350.
@@ -1719,6 +1749,10 @@ public Map<String, Object> getConstants() {
17191749
constants.put("reproStepsEnabled", ENABLED);
17201750
constants.put("reproStepsDisabled", DISABLED);
17211751

1752+
constants.put("welcomeMessageModeLive", WELCOME_MESSAGE_MODE_LIVE);
1753+
constants.put("welcomeMessageModeBeta", WELCOME_MESSAGE_MODE_BETA);
1754+
constants.put("welcomeMessageModeDisabled", WELCOME_MESSAGE_MODE_DISABLED);
1755+
17221756
constants.put("allActions", ACTION_TYPE_ALL_ACTIONS);
17231757
constants.put("reportBugAction", ACTION_TYPE_REPORT_BUG);
17241758
constants.put("requestNewFeature", ACTION_TYPE_REQUEST_NEW_FEATURE);

index.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ module.exports = {
215215
},
216216

217217
/**
218+
* @deprecated Use {@link showWelcomeMessage} instead.
218219
* Present a view that educates the user on how to invoke the SDK with the
219220
* currently set invocation event.
220221
*/
@@ -286,6 +287,7 @@ module.exports = {
286287
},
287288

288289
/**
290+
* @deprecated Use {@link setEmailFieldRequiredForActions} instead.
289291
* Sets whether users are required to enter an email address or not when
290292
* sending reports.
291293
* Defaults to YES.
@@ -297,7 +299,6 @@ module.exports = {
297299
},
298300

299301
/**
300-
* @deprecated since version 2.3.0. Use {@link setEnabledAttachmentTypes} instead.
301302
* Sets whether users are required to enter an email address or not when
302303
* sending reports.
303304
* Defaults to YES.
@@ -993,6 +994,16 @@ module.exports = {
993994
Instabug.setShouldShowSurveysWelcomeScreen(shouldShowWelcomeScreen);
994995
},
995996

997+
/**
998+
* Shows the welcome message in a specific mode.
999+
* @param welcomeMessageMode An enum to set the welcome message mode to
1000+
* live, beta or disabled.
1001+
*
1002+
*/
1003+
showWelcomeMessage: function(welcomeMessageMode) {
1004+
Instabug.showWelcomeMessageWithMode(welcomeMessageMode);
1005+
},
1006+
9961007
/**
9971008
* The event used to invoke the feedback form
9981009
* @readonly
@@ -1120,6 +1131,17 @@ module.exports = {
11201131
topLeft: Instabug.topLeft
11211132
},
11221133

1134+
/**
1135+
* The welcome message mode.
1136+
* @readonly
1137+
* @enum {number}
1138+
*/
1139+
welcomeMessageMode: {
1140+
live: Instabug.welcomeMessageModeLive,
1141+
beta: Instabug.welcomeMessageModeBeta,
1142+
disabled: Instabug.welcomeMessageModeDisabled
1143+
},
1144+
11231145
/**
11241146
* Instabug action types.
11251147
* @readonly

ios/RNInstabug/InstabugReactBridge.m

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,11 @@ - (dispatch_queue_t)methodQueue {
423423
}
424424

425425
[Instabug setEmailFieldRequired:isEmailFieldRequired forAction:actionTypes];
426-
}
426+
}
427+
428+
RCT_EXPORT_METHOD(showWelcomeMessageWithMode:(IBGWelcomeMessageMode)welcomeMessageMode) {
429+
[Instabug showWelcomeMessageWithMode:welcomeMessageMode];
430+
}
427431

428432
RCT_EXPORT_METHOD(isRunningLive:(RCTResponseSenderBlock)callback) {
429433
BOOL result = NO;
@@ -508,6 +512,10 @@ - (NSDictionary *)constantsToExport
508512
@"enabledWithOptionalFields": @(IBGExtendedBugReportModeEnabledWithOptionalFields),
509513
@"disabled": @(IBGExtendedBugReportModeDisabled),
510514

515+
@"welcomeMessageModeLive": @(IBGWelcomeMessageModeLive),
516+
@"welcomeMessageModeBeta": @(IBGWelcomeMessageModeBeta),
517+
@"welcomeMessageModeDisabled": @(IBGWelcomeMessageModeDisabled),
518+
511519
@"shakeHint": @(IBGStringShakeHint),
512520
@"swipeHint": @(IBGStringSwipeHint),
513521
@"edgeSwipeStartHint": @(IBGStringEdgeSwipeStartHint),

ios/RNInstabug/RCTConvert+InstabugEnums.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ @implementation RCTConvert (InstabugEnums)
9292
@"topLeft": @(IBGPositionTopLeft)
9393
}), IBGPositionBottomRight, integerValue);
9494

95+
RCT_ENUM_CONVERTER(IBGWelcomeMessageMode, (@{
96+
@"welcomeMessageModeLive": @(IBGWelcomeMessageModeLive),
97+
@"welcomeMessageModeBeta": @(IBGWelcomeMessageModeBeta),
98+
@"welcomeMessageModeDisabled": @(IBGWelcomeMessageModeDisabled)
99+
}), IBGWelcomeMessageModeLive, integerValue);
100+
95101

96102
RCT_ENUM_CONVERTER(IBGActionType, (@{
97103
@"allActions": @(IBGActionAllActions),

0 commit comments

Comments
 (0)