Skip to content

Commit 7b202ca

Browse files
committed
bridge: add setAttributionIdentifier api
1 parent 95bdf7b commit 7b202ca

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

android/src/main/java/com/batch/batch_rn/RNBatchModule.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,14 @@ public void userData_save(ReadableArray actions) {
642642
String value = action.getString("value");
643643
editor.setRegion(value);
644644
}
645+
} else if (type.equals("setAttributionId")) {
646+
ReadableType valueType = action.getType("value");
647+
if (valueType.equals(ReadableType.Null)) {
648+
editor.setAttributionIdentifier(null);
649+
} else {
650+
String value = action.getString("value");
651+
editor.setAttributionIdentifier(value);
652+
}
645653
} else if (type.equals("addTag")) {
646654
String collection = action.getString("collection");
647655
String tag = action.getString("tag");

ios/RNBatch.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,6 @@ -(void)stopObserving {
302302

303303
else if([type isEqualToString:@"setIdentifier"]) {
304304
[editor setIdentifier:[self safeNilValue:action[@"value"]]];
305-
306305
}
307306

308307
else if([type isEqualToString:@"setEmail"]) {
@@ -326,6 +325,10 @@ -(void)stopObserving {
326325
[editor setRegion:[self safeNilValue:action[@"value"]]];
327326
}
328327

328+
else if([type isEqualToString:@"setAttributionId"]) {
329+
[editor setAttributionIdentifier:[self safeNilValue:action[@"value"]]];
330+
}
331+
329332
else if([type isEqualToString:@"addTag"]) {
330333
[editor addTag:action[@"tag"] inCollection:action[@"collection"]];
331334
}

src/BatchUserEditor.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ interface IUserSettingsSetEmailMarketingSubscriptionStateAction {
6161
value: BatchEmailSubscriptionState;
6262
}
6363

64+
interface IUserSettingsSetAttributionIdAction {
65+
type: 'setAttributionId';
66+
value: string | null;
67+
}
68+
6469
interface IUserSettingsAddTagAction {
6570
type: 'addTag';
6671
collection: string;
@@ -96,7 +101,8 @@ type IUserSettingsAction =
96101
| IUserSettingsClearTagsAction
97102
| IUserSettingsClearTagCollectionAction
98103
| IUserSettingsSetEmailAction
99-
| IUserSettingsSetEmailMarketingSubscriptionStateAction;
104+
| IUserSettingsSetEmailMarketingSubscriptionStateAction
105+
| IUserSettingsSetAttributionIdAction;
100106

101107
type IUserSettingsActions = IUserSettingsAction[];
102108

@@ -187,6 +193,13 @@ export class BatchUserEditor {
187193
});
188194
}
189195

196+
public setAttributionIdentifier(value: string | null): BatchUserEditor {
197+
return this.addAction({
198+
type: 'setAttributionId',
199+
value,
200+
});
201+
}
202+
190203
public addTag(collection: string, tag: string): BatchUserEditor {
191204
return this.addAction({
192205
type: 'addTag',

0 commit comments

Comments
 (0)