Skip to content

Commit 5d8c543

Browse files
committed
refactor: update parameter types in RNIterableAPI to use Double to match codegen
1 parent 32c7eb8 commit 5d8c543

File tree

2 files changed

+49
-50
lines changed

2 files changed

+49
-50
lines changed

ios/RNIterableAPI/RNIterableAPI.mm

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ - (void)getUserId:(RCTPromiseResolveBlock)resolve
106106
[_swiftAPI getUserId:resolve rejecter:reject];
107107
}
108108

109-
- (void)setInAppShowResponse:(NSNumber *_Nonnull)inAppShowResponse {
109+
- (void)setInAppShowResponse:(double)inAppShowResponse {
110110
[_swiftAPI setInAppShowResponse:inAppShowResponse];
111111
}
112112

@@ -137,8 +137,8 @@ - (void)showMessage:(NSString *)messageId
137137
}
138138

139139
- (void)removeMessage:(NSString *)messageId
140-
location:(NSNumber *_Nonnull)location
141-
source:(NSNumber *_Nonnull)source {
140+
location:(double)location
141+
source:(double)source {
142142
[_swiftAPI removeMessage:messageId location:location source:source];
143143
}
144144

@@ -154,8 +154,8 @@ - (void)trackEvent:(NSString *)name dataFields:(NSDictionary *)dataFields {
154154
[_swiftAPI trackEvent:name dataFields:dataFields];
155155
}
156156

157-
- (void)trackPushOpenWithCampaignId:(NSNumber *_Nonnull)campaignId
158-
templateId:(NSNumber *_Nonnull)templateId
157+
- (void)trackPushOpenWithCampaignId:(double)campaignId
158+
templateId:(NSNumber *)templateId
159159
messageId:(NSString *)messageId
160160
appAlreadyRunning:(BOOL)appAlreadyRunning
161161
dataFields:(NSDictionary *)dataFields {
@@ -166,20 +166,19 @@ - (void)trackPushOpenWithCampaignId:(NSNumber *_Nonnull)campaignId
166166
dataFields:dataFields];
167167
}
168168

169-
- (void)trackInAppOpen:(NSString *)messageId
170-
location:(NSNumber *_Nonnull)location {
169+
- (void)trackInAppOpen:(NSString *)messageId location:(double)location {
171170
[_swiftAPI trackInAppOpen:messageId location:location];
172171
}
173172

174173
- (void)trackInAppClick:(NSString *)messageId
175-
location:(NSNumber *_Nonnull)location
174+
location:(double)location
176175
clickedUrl:(NSString *)clickedUrl {
177176
[_swiftAPI trackInAppClick:messageId location:location clickedUrl:clickedUrl];
178177
}
179178

180179
- (void)trackInAppClose:(NSString *)messageId
181-
location:(NSNumber *_Nonnull)location
182-
source:(NSNumber *_Nonnull)source
180+
location:(double)location
181+
source:(double)source
183182
clickedUrl:(NSString *)clickedUrl {
184183
[_swiftAPI trackInAppClose:messageId
185184
location:location
@@ -188,16 +187,16 @@ - (void)trackInAppClose:(NSString *)messageId
188187
}
189188

190189
- (void)inAppConsume:(NSString *)messageId
191-
location:(NSNumber *_Nonnull)location
192-
source:(NSNumber *_Nonnull)source {
190+
location:(double)location
191+
source:(double)source {
193192
[_swiftAPI inAppConsume:messageId location:location source:source];
194193
}
195194

196195
- (void)updateCart:(NSArray *)items {
197196
[_swiftAPI updateCart:items];
198197
}
199198

200-
- (void)trackPurchase:(NSNumber *_Nonnull)total
199+
- (void)trackPurchase:(double)total
201200
items:(NSArray *)items
202201
dataFields:(NSDictionary *)dataFields {
203202
[_swiftAPI trackPurchase:total items:items dataFields:dataFields];
@@ -217,7 +216,7 @@ - (void)getAttributionInfo:(RCTPromiseResolveBlock)resolve
217216
[_swiftAPI getAttributionInfo:resolve rejecter:reject];
218217
}
219218

220-
- (void)setAttributionInfo:(NSDictionary *)attributionInfo {
219+
- (void)setAttributionInfo:(NSDictionary *_Nullable)attributionInfo {
221220
[_swiftAPI setAttributionInfo:attributionInfo];
222221
}
223222

@@ -244,12 +243,12 @@ - (void)handleAppLink:(NSString *)appLink
244243
[_swiftAPI handleAppLink:appLink resolver:resolve rejecter:reject];
245244
}
246245

247-
- (void)updateSubscriptions:(NSArray *)emailListIds
248-
unsubscribedChannelIds:(NSArray *)unsubscribedChannelIds
249-
unsubscribedMessageTypeIds:(NSArray *)unsubscribedMessageTypeIds
250-
subscribedMessageTypeIds:(NSArray *)subscribedMessageTypeIds
251-
campaignId:(NSNumber *_Nonnull)campaignId
252-
templateId:(NSNumber *_Nonnull)templateId {
246+
- (void)updateSubscriptions:(NSArray *_Nullable)emailListIds
247+
unsubscribedChannelIds:(NSArray *_Nullable)unsubscribedChannelIds
248+
unsubscribedMessageTypeIds:(NSArray *_Nullable)unsubscribedMessageTypeIds
249+
subscribedMessageTypeIds:(NSArray *_Nullable)subscribedMessageTypeIds
250+
campaignId:(double)campaignId
251+
templateId:(double)templateId {
253252
[_swiftAPI updateSubscriptions:emailListIds
254253
unsubscribedChannelIds:unsubscribedChannelIds
255254
unsubscribedMessageTypeIds:unsubscribedMessageTypeIds
@@ -270,7 +269,7 @@ - (void)updateVisibleRows:(NSArray *)visibleRows {
270269
[_swiftAPI updateVisibleRows:visibleRows];
271270
}
272271

273-
- (void)passAlongAuthToken:(NSString *)authToken {
272+
- (void)passAlongAuthToken:(NSString *_Nullable)authToken {
274273
[_swiftAPI passAlongAuthToken:authToken];
275274
}
276275

ios/RNIterableAPI/ReactIterableAPI.swift

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ import React
130130
// MARK: - Iterable API Request Functions
131131

132132
@objc(setInAppShowResponse:)
133-
public func setInAppShowResponse(inAppShowResponse number: NSNumber) {
133+
public func setInAppShowResponse(inAppShowResponse number: Double) {
134134
ITBInfo()
135-
self.inAppShowResponse = InAppShowResponse.from(number: number)
135+
self.inAppShowResponse = InAppShowResponse.from(number: number as NSNumber)
136136
inAppHandlerSemaphore.signal()
137137
}
138138

@@ -173,7 +173,7 @@ import React
173173

174174
@objc(trackPushOpenWithCampaignId:templateId:messageId:appAlreadyRunning:dataFields:)
175175
public func trackPushOpenWithCampaignId(
176-
campaignId: NSNumber,
176+
campaignId: Double,
177177
templateId: NSNumber?,
178178
messageId: String,
179179
appAlreadyRunning: Bool,
@@ -183,7 +183,7 @@ import React
183183
let swiftDict = dataFields as? [AnyHashable: Any]
184184

185185
IterableAPI.track(
186-
pushOpen: campaignId,
186+
pushOpen: campaignId as NSNumber,
187187
templateId: templateId,
188188
messageId: messageId,
189189
appAlreadyRunning: appAlreadyRunning,
@@ -198,34 +198,34 @@ import React
198198

199199
@objc(trackPurchase:items:dataFields:)
200200
public func trackPurchase(
201-
total: NSNumber,
201+
total: Double,
202202
items: [[AnyHashable: Any]],
203203
dataFields: [AnyHashable: Any]?
204204
) {
205205
ITBInfo()
206206
IterableAPI.track(
207-
purchase: total,
207+
purchase: total as NSNumber,
208208
items: items.compactMap(CommerceItem.from(dict:)),
209209
dataFields: dataFields)
210210
}
211211

212212
@objc(trackInAppOpen:location:)
213213
public func trackInAppOpen(
214214
messageId: String,
215-
location locationNumber: NSNumber
215+
location locationNumber: Double
216216
) {
217217
ITBInfo()
218218
guard let message = IterableAPI.inAppManager.getMessage(withId: messageId) else {
219219
ITBError("Could not find message with id: \(messageId)")
220220
return
221221
}
222-
IterableAPI.track(inAppOpen: message, location: InAppLocation.from(number: locationNumber))
222+
IterableAPI.track(inAppOpen: message, location: InAppLocation.from(number: locationNumber as NSNumber))
223223
}
224224

225225
@objc(trackInAppClick:location:clickedUrl:)
226226
public func trackInAppClick(
227227
messageId: String,
228-
location locationNumber: NSNumber,
228+
location locationNumber: Double,
229229
clickedUrl: String
230230
) {
231231
ITBInfo()
@@ -234,56 +234,56 @@ import React
234234
return
235235
}
236236
IterableAPI.track(
237-
inAppClick: message, location: InAppLocation.from(number: locationNumber),
237+
inAppClick: message, location: InAppLocation.from(number: locationNumber as NSNumber),
238238
clickedUrl: clickedUrl)
239239
}
240240

241241
@objc(trackInAppClose:location:source:clickedUrl:)
242242
public func trackInAppClose(
243243
messageId: String,
244-
location locationNumber: NSNumber,
245-
source sourceNumber: NSNumber,
244+
location locationNumber: Double,
245+
source sourceNumber: Double,
246246
clickedUrl: String?
247247
) {
248248
ITBInfo()
249249
guard let message = IterableAPI.inAppManager.getMessage(withId: messageId) else {
250250
ITBError("Could not find message with id: \(messageId)")
251251
return
252252
}
253-
if let inAppCloseSource = InAppCloseSource.from(number: sourceNumber) {
253+
if let inAppCloseSource = InAppCloseSource.from(number: sourceNumber as NSNumber) {
254254
IterableAPI.track(
255255
inAppClose: message,
256-
location: InAppLocation.from(number: locationNumber),
256+
location: InAppLocation.from(number: locationNumber as NSNumber),
257257
source: inAppCloseSource,
258258
clickedUrl: clickedUrl)
259259
} else {
260260
IterableAPI.track(
261261
inAppClose: message,
262-
location: InAppLocation.from(number: locationNumber),
262+
location: InAppLocation.from(number: locationNumber as NSNumber),
263263
clickedUrl: clickedUrl)
264264
}
265265
}
266266

267267
@objc(inAppConsume:location:source:)
268268
public func inAppConsume(
269269
messageId: String,
270-
location locationNumber: NSNumber,
271-
source sourceNumber: NSNumber
270+
location locationNumber: Double,
271+
source sourceNumber: Double
272272
) {
273273
ITBInfo()
274274
guard let message = IterableAPI.inAppManager.getMessage(withId: messageId) else {
275275
ITBError("Could not find message with id: \(messageId)")
276276
return
277277
}
278-
if let inAppDeleteSource = InAppDeleteSource.from(number: sourceNumber) {
278+
if let inAppDeleteSource = InAppDeleteSource.from(number: sourceNumber as NSNumber) {
279279
IterableAPI.inAppConsume(
280280
message: message,
281-
location: InAppLocation.from(number: locationNumber),
281+
location: InAppLocation.from(number: locationNumber as NSNumber),
282282
source: inAppDeleteSource)
283283
} else {
284284
IterableAPI.inAppConsume(
285285
message: message,
286-
location: InAppLocation.from(number: locationNumber))
286+
location: InAppLocation.from(number: locationNumber as NSNumber))
287287
}
288288
}
289289

@@ -386,22 +386,22 @@ import React
386386

387387
@objc(removeMessage:location:source:)
388388
public func removeMessage(
389-
messageId: String, location locationNumber: NSNumber, source sourceNumber: NSNumber
389+
messageId: String, location locationNumber: Double, source sourceNumber: Double
390390
) {
391391
ITBInfo()
392392
guard let message = IterableAPI.inAppManager.getMessage(withId: messageId) else {
393393
ITBError("Could not find message with id: \(messageId)")
394394
return
395395
}
396-
if let inAppDeleteSource = InAppDeleteSource.from(number: sourceNumber) {
396+
if let inAppDeleteSource = InAppDeleteSource.from(number: sourceNumber as NSNumber) {
397397
IterableAPI.inAppManager.remove(
398398
message: message,
399-
location: InAppLocation.from(number: locationNumber),
400-
source: inAppDeleteSource)
399+
location: InAppLocation.from(number: locationNumber as NSNumber),
400+
source: inAppDeleteSource as InAppDeleteSource)
401401
} else {
402402
IterableAPI.inAppManager.remove(
403403
message: message,
404-
location: InAppLocation.from(number: locationNumber))
404+
location: InAppLocation.from(number: locationNumber as NSNumber))
405405
}
406406
}
407407

@@ -414,12 +414,12 @@ import React
414414
unsubscribedChannelIds: [NSNumber]?,
415415
unsubscribedMessageTypeIds: [NSNumber]?,
416416
subscribedMessageTypeIds: [NSNumber]?,
417-
campaignId: NSNumber,
418-
templateId: NSNumber
417+
campaignId: Double,
418+
templateId: Double
419419
) {
420420
ITBInfo()
421-
let finalCampaignId: NSNumber? = campaignId.intValue <= 0 ? nil : campaignId
422-
let finalTemplateId: NSNumber? = templateId.intValue <= 0 ? nil : templateId
421+
let finalCampaignId: NSNumber? = campaignId <= 0 ? nil : campaignId as NSNumber
422+
let finalTemplateId: NSNumber? = templateId <= 0 ? nil : templateId as NSNumber
423423
IterableAPI.updateSubscriptions(
424424
emailListIds,
425425
unsubscribedChannelIds: unsubscribedChannelIds,

0 commit comments

Comments
 (0)