Skip to content

Commit 937dc34

Browse files
Add iOS API removeUserAttribute
1 parent 6368906 commit 937dc34

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/ios/IBGPlugin.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,6 @@
3838

3939
- (void)setUserAttribute:(CDVInvokedUrlCommand *)command;
4040

41+
- (void)removeUserAttribute:(CDVInvokedUrlCommand *)command;
42+
4143
@end

src/ios/IBGPlugin.m

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,6 +1246,27 @@ - (void) setUserAttribute:(CDVInvokedUrlCommand*)command
12461246
[self.commandDelegate sendPluginResult:result callbackId:[command callbackId]];
12471247
}
12481248

1249+
/**
1250+
* Removes a given key and its associated value from user attributes.
1251+
* Does nothing if a key does not exist.
1252+
*/
1253+
- (void) removeUserAttribute:(CDVInvokedUrlCommand*)command
1254+
{
1255+
CDVPluginResult* result;
1256+
1257+
NSString* key = [command argumentAtIndex:0];
1258+
1259+
if (key) {
1260+
[Instabug removeUserAttributeForKey:key];
1261+
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
1262+
} else {
1263+
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
1264+
messageAsString:@"key parameter must be provided."];
1265+
}
1266+
1267+
[self.commandDelegate sendPluginResult:result callbackId:[command callbackId]];
1268+
}
1269+
12491270
/**
12501271
* Shows one of the surveys that were not shown before, that also have
12511272
* conditions that match the current device/user.

0 commit comments

Comments
 (0)