Skip to content

Commit 3583558

Browse files
committed
refactor: add getAttributionInfo method to ReactIterableAPI and enhance Objective-C bridge for improved attribution data retrieval functionality
1 parent f96a5c9 commit 3583558

5 files changed

Lines changed: 22 additions & 7 deletions

File tree

example/src/components/Utility/Utility.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ export const Utility = () => {
2222
}}>
2323
<Text style={styles.buttonText}>Iterable.getUserId()</Text>
2424
</TouchableOpacity>
25+
<TouchableOpacity style={styles.button} onPress={() => {
26+
Iterable.getAttributionInfo().then((attributionInfo) => {
27+
console.log('Iterable.getAttributionInfo() --> attributionInfo', attributionInfo);
28+
});
29+
}}>
30+
<Text style={styles.buttonText}>Iterable.getAttributionInfo()</Text>
31+
</TouchableOpacity>
2532
</View>
2633
);
2734
};

ios/RNIterableAPI/RNIterableAPI.mm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,13 @@ - (void)updateEmail:(NSString *)email
232232
[_swiftAPI updateEmail:email authToken:authToken];
233233
}
234234

235+
- (void)getAttributionInfo:(RCTPromiseResolveBlock)resolve
236+
reject:(RCTPromiseRejectBlock)reject
237+
{
238+
NSLog(@"ReactNativeSdk getAttributionInfo");
239+
[_swiftAPI getAttributionInfo:resolve rejecter:reject];
240+
}
241+
235242
@end
236243

237244

ios/RNIterableAPI/ReactIterableAPI.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ open class ReactIterableAPI: RCTEventEmitter {
165165
}
166166

167167
@objc(getAttributionInfo:rejecter:)
168-
func getAttributionInfo(resolver: RCTPromiseResolveBlock, rejecter: RCTPromiseRejectBlock) {
168+
public func getAttributionInfo(resolver: RCTPromiseResolveBlock, rejecter: RCTPromiseRejectBlock)
169+
{
169170
ITBInfo()
170171
resolver(IterableAPI.attributionInfo.map(SerializationUtil.encodableToDictionary))
171172
}

src/api/NativeRNIterableAPI.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ export interface Spec extends TurboModule {
9494
): void;
9595
updateEmail(email: string, authToken?: string): void;
9696

97-
// // Attribution
98-
// getAttributionInfo(): Promise<{
99-
// [key: string]: string | number | boolean;
100-
// } | null>;
97+
// Attribution
98+
getAttributionInfo(): Promise<{
99+
[key: string]: string | number | boolean;
100+
} | null>;
101101
// setAttributionInfo(
102102
// dict: { [key: string]: string | number | boolean } | null
103103
// ): void;

src/core/classes/Iterable.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,8 @@ export class Iterable {
326326
static getAttributionInfo(): Promise<IterableAttributionInfo | undefined> {
327327
Iterable?.logger?.log('getAttributionInfo');
328328

329-
return RNIterableAPI.getAttributionInfo().then(
330-
(dict?: IterableAttributionInfo) => {
329+
return api.getAttributionInfo().then(
330+
(dict?: { [key: string]: string | number | boolean } | null) => {
331331
if (dict) {
332332
return new IterableAttributionInfo(
333333
dict.campaignId,

0 commit comments

Comments
 (0)