Skip to content

Commit

Permalink
bridge: add setAttributionIdentifier api
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaud-roland committed Dec 27, 2023
1 parent 89fd2e4 commit 58669d9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
8 changes: 8 additions & 0 deletions android/src/main/java/com/batch/batch_rn/RNBatchModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,14 @@ public void userData_save(ReadableArray actions) {
String value = action.getString("value");
editor.setRegion(value);
}
} else if (type.equals("setAttributionId")) {
ReadableType valueType = action.getType("value");
if (valueType.equals(ReadableType.Null)) {
editor.setAttributionIdentifier(null);
} else {
String value = action.getString("value");
editor.setAttributionIdentifier(value);
}
} else if (type.equals("addTag")) {
String collection = action.getString("collection");
String tag = action.getString("tag");
Expand Down
5 changes: 4 additions & 1 deletion ios/RNBatch.m
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,6 @@ -(void)stopObserving {

else if([type isEqualToString:@"setIdentifier"]) {
[editor setIdentifier:[self safeNilValue:action[@"value"]]];

}

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

else if([type isEqualToString:@"setAttributionId"]) {
[editor setAttributionIdentifier:[self safeNilValue:action[@"value"]]];
}

else if([type isEqualToString:@"addTag"]) {
[editor addTag:action[@"tag"] inCollection:action[@"collection"]];
}
Expand Down
15 changes: 14 additions & 1 deletion src/BatchUserEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ interface IUserSettingsSetEmailMarketingSubscriptionStateAction {
value: BatchEmailSubscriptionState;
}

interface IUserSettingsSetAttributionIdAction {
type: 'setAttributionId';
value: string | null;
}

interface IUserSettingsAddTagAction {
type: 'addTag';
collection: string;
Expand Down Expand Up @@ -96,7 +101,8 @@ type IUserSettingsAction =
| IUserSettingsClearTagsAction
| IUserSettingsClearTagCollectionAction
| IUserSettingsSetEmailAction
| IUserSettingsSetEmailMarketingSubscriptionStateAction;
| IUserSettingsSetEmailMarketingSubscriptionStateAction
| IUserSettingsSetAttributionIdAction;

type IUserSettingsActions = IUserSettingsAction[];

Expand Down Expand Up @@ -187,6 +193,13 @@ export class BatchUserEditor {
});
}

public setAttributionIdentifier(value: string | null): BatchUserEditor {
return this.addAction({
type: 'setAttributionId',
value,
});
}

public addTag(collection: string, tag: string): BatchUserEditor {
return this.addAction({
type: 'addTag',
Expand Down

0 comments on commit 58669d9

Please sign in to comment.