|
2 | 2 |
|
3 | 3 | #if RCT_NEW_ARCH_ENABLED |
4 | 4 | #import "RNIterableAPISpec.h" |
| 5 | + #import <string> |
5 | 6 | #endif |
6 | 7 |
|
7 | 8 | #import <IterableSDK/IterableSDK.h> |
@@ -303,6 +304,30 @@ - (void)pauseEmbeddedImpression:(NSString *)messageId { |
303 | 304 | [_swiftAPI pauseEmbeddedImpression:messageId]; |
304 | 305 | } |
305 | 306 |
|
| 307 | +- (void)trackEmbeddedClick:(JS::NativeRNIterableAPI::EmbeddedMessage &)message |
| 308 | + buttonId:(NSString *_Nullable)buttonId |
| 309 | + clickedUrl:(NSString *_Nullable)clickedUrl { |
| 310 | + // The TurboModule bridge requires us to use the C++ type in the signature, |
| 311 | + // but we need to convert it to NSDictionary to pass to Swift. |
| 312 | + // The C++ struct wraps an NSDictionary, and the generated methods already |
| 313 | + // return NSString*/NSNumber* types, so we just need to reconstruct the dict. |
| 314 | + NSMutableDictionary *messageDict = [NSMutableDictionary new]; |
| 315 | + |
| 316 | + // Convert metadata (the accessor methods already return proper ObjC types) |
| 317 | + NSMutableDictionary *metadataDict = [NSMutableDictionary new]; |
| 318 | + metadataDict[@"messageId"] = message.metadata().messageId(); |
| 319 | + metadataDict[@"placementId"] = @(message.metadata().placementId()); |
| 320 | + if (message.metadata().campaignId().has_value()) { |
| 321 | + metadataDict[@"campaignId"] = @(*message.metadata().campaignId()); |
| 322 | + } |
| 323 | + if (message.metadata().isProof().has_value()) { |
| 324 | + metadataDict[@"isProof"] = @(*message.metadata().isProof()); |
| 325 | + } |
| 326 | + messageDict[@"metadata"] = metadataDict; |
| 327 | + |
| 328 | + [_swiftAPI trackEmbeddedClick:messageDict buttonId:buttonId clickedUrl:clickedUrl]; |
| 329 | +} |
| 330 | + |
306 | 331 | - (void)wakeApp { |
307 | 332 | // Placeholder function -- this method is only used in Android |
308 | 333 | } |
@@ -557,6 +582,10 @@ - (void)wakeApp { |
557 | 582 | [_swiftAPI pauseEmbeddedImpression:messageId]; |
558 | 583 | } |
559 | 584 |
|
| 585 | +RCT_EXPORT_METHOD(trackEmbeddedClick : (NSDictionary *)message buttonId : (NSString *_Nullable)buttonId clickedUrl : (NSString *_Nullable)clickedUrl) { |
| 586 | + [_swiftAPI trackEmbeddedClick:message buttonId:buttonId clickedUrl:clickedUrl]; |
| 587 | +} |
| 588 | + |
560 | 589 | RCT_EXPORT_METHOD(wakeApp) { |
561 | 590 | // Placeholder function -- this method is only used in Android |
562 | 591 | } |
|
0 commit comments