Skip to content

Commit 4057571

Browse files
Add iOS native helper: [IBGPlugin setColorTheme]
1 parent dcf82bc commit 4057571

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

src/ios/IBGPlugin.m

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,7 +1075,7 @@ - (void) setWelcomeMessageMode:(NSString*)welcomeMessageMode
10751075
* @param {NSString*} theme
10761076
* NSString representation of color theme
10771077
*/
1078-
- (void) setColorTheme:(NSString*)theme
1078+
- (void) setColorThemeInOptions:(NSString*)theme
10791079
{
10801080
if ([theme isEqualToString:@"dark"]) {
10811081
[Instabug setColorTheme:IBGColorThemeDark];
@@ -1084,6 +1084,36 @@ - (void) setColorTheme:(NSString*)theme
10841084
}
10851085
}
10861086

1087+
/**
1088+
* Sets the SDK color theme
1089+
*
1090+
* @param {CDVInvokedUrlCommand*} command
1091+
* The command sent from JavaScript
1092+
*/
1093+
- (void) setColorTheme:(CDVInvokedUrlCommand*)command
1094+
{
1095+
CDVPluginResult* result;
1096+
NSString* theme = [command argumentAtIndex:0];
1097+
1098+
if ([theme length] > 0) {
1099+
if ([theme isEqualToString:@"dark"]) {
1100+
[Instabug setColorTheme:IBGColorThemeDark];
1101+
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
1102+
} else if ([theme isEqualToString:@"light"]) {
1103+
[Instabug setColorTheme:IBGColorThemeLight];
1104+
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
1105+
} else {
1106+
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
1107+
messageAsString:@"Color theme value is not valid."];
1108+
}
1109+
} else {
1110+
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
1111+
messageAsString:@"Color theme must be provided."];
1112+
}
1113+
1114+
[self.commandDelegate sendPluginResult:result callbackId:[command callbackId]];
1115+
}
1116+
10871117
/**
10881118
* Sets a threshold for numbers of sessions and another for number of days
10891119
* required before a survey, that has been dismissed once, would show again.
@@ -1244,7 +1274,7 @@ - (void) applyOptions:(NSDictionary*)options
12441274
[self setTrackingUserStepsEnabled:[[options objectForKey:@"enableTrackingUserSteps"] stringValue]];
12451275
[self setPushNotificationsEnabled:[[options objectForKey:@"enablePushNotifications"] stringValue]];
12461276
[self setSessionProfilerEnabled:[[options objectForKey:@"enableSessionProfiler"] stringValue]];
1247-
[self setColorTheme:[options objectForKey:@"colorTheme"]];
1277+
[self setColorThemeInOptions:[options objectForKey:@"colorTheme"]];
12481278
[self setWelcomeMessageMode:[options objectForKey:@"welcomeMessageMode"]];
12491279
}
12501280

0 commit comments

Comments
 (0)