Skip to content

Commit d7bb371

Browse files
Convert trackInAppClick.
1 parent a981347 commit d7bb371

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

Iterable.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,27 @@ class Iterable {
246246
RNIterableAPI.trackPurchase(total, items, dataFields)
247247
}
248248

249+
/**
250+
*
251+
* @param {IterableInAppMessage} message
252+
* @param {IterableInAppLocation} location
253+
*/
249254
static trackInAppOpen(message: IterableInAppMessage, location: IterableInAppLocation) {
250255
console.log("trackInAppOpen")
251256
RNIterableAPI.trackInAppOpen(message.messageId, location)
252257
}
253258

259+
/**
260+
*
261+
* @param {IterableInAppMessage} message
262+
* @param {IterableInAppLocation} location
263+
* @param {String} clickedUrl
264+
*/
265+
static trackInAppClick(message: IterableInAppMessage, location: IterableInAppLocation, clickedUrl: String) {
266+
console.log("trackInAppClick")
267+
RNIterableAPI.trackInAppClick(message.messageId, location, clickedUrl)
268+
}
269+
254270
static getInAppMessages(): Promise<Array<IterableInAppMessage>> {
255271
console.log("getInAppMessages");
256272
return RNIterableAPI.getInAppMessages().then((messages: Array<any>) => messages.map (message => {return IterableInAppMessage.fromDict(message)}))

index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ export class Iterable {
88
static disableDeviceForAllUsers(): void
99
static getInAppMessages(): void
1010
static getLastPushPayload(): Promise<any | null>
11-
static getLastPushPayload(): Promise<any | null>
1211
static getAttributionInfo(): Promise<IterableAttributionInfo | null>
1312
static setAttributionInfo(attributionInfo?: IterableAttributionInfo): void
1413
static trackPushOpenWithPayload(payload: any, dataFields: any | null): void
1514
static trackPushOpenWithCampaignId(campaignId: number, templateId: number, messageId: String | null, appAlreadyRunning: Boolean, dataFields: any | null): void
1615
static trackPurchase(total: number, items: Array<IterableCommerceItem>, dataFields: any | null): void
1716
static trackInAppOpen(message: IterableInAppMessage, location: IterableInAppLocation): void
17+
static trackInAppClick(message: IterableInAppMessage, location: IterableInAppLocation, clickedUrl: String): void
1818
}
1919

2020
export enum PushServicePlatform {

ios/RNIterableAPI/RNIterableAPI.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ @interface RCT_EXTERN_REMAP_MODULE(RNIterableAPI, ReactIterableAPI, NSObject)
5252
RCT_EXTERN_METHOD(trackInAppOpen: (NSString *) messageId
5353
location: (nonnull NSNumber *) location)
5454

55-
RCT_EXTERN_METHOD(trackInAppClick: (NSString *) messageId
56-
location: (nonnull NSNumber *) location)
55+
RCT_EXTERN_METHOD(trackInAppClick: (nonnull NSString *) messageId
56+
location: (nonnull NSNumber *) location
57+
clickedUrl: (nonnull NSString *) clickedUrl)
5758

5859
RCT_EXTERN_METHOD(getInAppMessages: (RCTPromiseResolveBlock) resolve
5960
rejecter: (RCTPromiseRejectBlock) reject)

ios/RNIterableAPI/ReactIterableAPI.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,16 @@ class ReactIterableAPI: RCTEventEmitter {
179179
IterableAPI.track(inAppOpen: message, location: InAppLocation.from(number: number))
180180
}
181181

182+
@objc(trackInAppClick:location:clickedUrl:)
183+
func trackInAppClick(messageId: String, location number: NSNumber, clickedUrl: String) {
184+
ITBInfo()
185+
guard let message = IterableAPI.inAppManager.getMessage(withId: messageId) else {
186+
ITBError("Could not find message with id: \(messageId)")
187+
return
188+
}
189+
IterableAPI.track(inAppClick: message, location: InAppLocation.from(number: number), clickedUrl: clickedUrl)
190+
}
191+
182192
@objc(getInAppMessages:rejecter:)
183193
func getInAppMessages(resolver: RCTPromiseResolveBlock, rejecter: RCTPromiseRejectBlock) {
184194
ITBInfo()

0 commit comments

Comments
 (0)