Skip to content

Commit 32c7eb8

Browse files
committed
refactor: update ios interfaces to enforce non-nullable parameters for better safety
1 parent f45c778 commit 32c7eb8

File tree

2 files changed

+33
-34
lines changed

2 files changed

+33
-34
lines changed

ios/RNIterableAPI/RNIterableAPI.mm

Lines changed: 33 additions & 31 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 *)inAppShowResponse {
109+
- (void)setInAppShowResponse:(NSNumber *_Nonnull)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 *)location
141-
source:(NSNumber *)source {
140+
location:(NSNumber *_Nonnull)location
141+
source:(NSNumber *_Nonnull)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 *)campaignId
158-
templateId:(NSNumber *)templateId
157+
- (void)trackPushOpenWithCampaignId:(NSNumber *_Nonnull)campaignId
158+
templateId:(NSNumber *_Nonnull)templateId
159159
messageId:(NSString *)messageId
160160
appAlreadyRunning:(BOOL)appAlreadyRunning
161161
dataFields:(NSDictionary *)dataFields {
@@ -166,19 +166,20 @@ - (void)trackPushOpenWithCampaignId:(NSNumber *)campaignId
166166
dataFields:dataFields];
167167
}
168168

169-
- (void)trackInAppOpen:(NSString *)messageId location:(NSNumber *)location {
169+
- (void)trackInAppOpen:(NSString *)messageId
170+
location:(NSNumber *_Nonnull)location {
170171
[_swiftAPI trackInAppOpen:messageId location:location];
171172
}
172173

173174
- (void)trackInAppClick:(NSString *)messageId
174-
location:(NSNumber *)location
175+
location:(NSNumber *_Nonnull)location
175176
clickedUrl:(NSString *)clickedUrl {
176177
[_swiftAPI trackInAppClick:messageId location:location clickedUrl:clickedUrl];
177178
}
178179

179180
- (void)trackInAppClose:(NSString *)messageId
180-
location:(NSNumber *)location
181-
source:(NSNumber *)source
181+
location:(NSNumber *_Nonnull)location
182+
source:(NSNumber *_Nonnull)source
182183
clickedUrl:(NSString *)clickedUrl {
183184
[_swiftAPI trackInAppClose:messageId
184185
location:location
@@ -187,16 +188,16 @@ - (void)trackInAppClose:(NSString *)messageId
187188
}
188189

189190
- (void)inAppConsume:(NSString *)messageId
190-
location:(NSNumber *)location
191-
source:(NSNumber *)source {
191+
location:(NSNumber *_Nonnull)location
192+
source:(NSNumber *_Nonnull)source {
192193
[_swiftAPI inAppConsume:messageId location:location source:source];
193194
}
194195

195196
- (void)updateCart:(NSArray *)items {
196197
[_swiftAPI updateCart:items];
197198
}
198199

199-
- (void)trackPurchase:(NSNumber *)total
200+
- (void)trackPurchase:(NSNumber *_Nonnull)total
200201
items:(NSArray *)items
201202
dataFields:(NSDictionary *)dataFields {
202203
[_swiftAPI trackPurchase:total items:items dataFields:dataFields];
@@ -247,8 +248,8 @@ - (void)updateSubscriptions:(NSArray *)emailListIds
247248
unsubscribedChannelIds:(NSArray *)unsubscribedChannelIds
248249
unsubscribedMessageTypeIds:(NSArray *)unsubscribedMessageTypeIds
249250
subscribedMessageTypeIds:(NSArray *)subscribedMessageTypeIds
250-
campaignId:(NSNumber *)campaignId
251-
templateId:(NSNumber *)templateId {
251+
campaignId:(NSNumber *_Nonnull)campaignId
252+
templateId:(NSNumber *_Nonnull)templateId {
252253
[_swiftAPI updateSubscriptions:emailListIds
253254
unsubscribedChannelIds:unsubscribedChannelIds
254255
unsubscribedMessageTypeIds:unsubscribedMessageTypeIds
@@ -335,7 +336,8 @@ - (void)passAlongAuthToken:(NSString *)authToken {
335336
[_swiftAPI getUserId:resolve rejecter:reject];
336337
}
337338

338-
RCT_EXPORT_METHOD(setInAppShowResponse : (NSNumber *)inAppShowResponse) {
339+
RCT_EXPORT_METHOD(setInAppShowResponse : (NSNumber *_Nonnull)
340+
inAppShowResponse) {
339341
[_swiftAPI setInAppShowResponse:inAppShowResponse];
340342
}
341343

@@ -363,8 +365,8 @@ - (void)passAlongAuthToken:(NSString *)authToken {
363365
rejecter:reject];
364366
}
365367

366-
RCT_EXPORT_METHOD(removeMessage : (NSString *)messageId location : (NSNumber *)
367-
location source : (NSNumber *)source) {
368+
RCT_EXPORT_METHOD(removeMessage : (NSString *)messageId location : (
369+
NSNumber *_Nonnull)location source : (NSNumber *_Nonnull)source) {
368370
[_swiftAPI removeMessage:messageId location:location source:source];
369371
}
370372

@@ -382,46 +384,46 @@ - (void)passAlongAuthToken:(NSString *)authToken {
382384
}
383385

384386
RCT_EXPORT_METHOD(
385-
trackPushOpenWithCampaignId : (NSNumber *)
386-
campaignId templateId : (NSNumber *)templateId messageId : (NSString *)
387-
messageId appAlreadyRunning : (BOOL)
388-
appAlreadyRunning dataFields : (NSDictionary *)dataFields) {
387+
trackPushOpenWithCampaignId : (NSNumber *_Nonnull)campaignId templateId : (
388+
NSNumber *_Nonnull)templateId messageId : (NSString *)
389+
messageId appAlreadyRunning : (BOOL)
390+
appAlreadyRunning dataFields : (NSDictionary *)dataFields) {
389391
[_swiftAPI trackPushOpenWithCampaignId:campaignId
390392
templateId:templateId
391393
messageId:messageId
392394
appAlreadyRunning:appAlreadyRunning
393395
dataFields:dataFields];
394396
}
395397

396-
RCT_EXPORT_METHOD(trackInAppOpen : (NSString *)messageId location : (NSNumber *)
397-
location) {
398+
RCT_EXPORT_METHOD(trackInAppOpen : (NSString *)
399+
messageId location : (NSNumber *_Nonnull)location) {
398400
[_swiftAPI trackInAppOpen:messageId location:location];
399401
}
400402

401403
RCT_EXPORT_METHOD(trackInAppClick : (NSString *)messageId location : (
402-
NSNumber *)location clickedUrl : (NSString *)clickedUrl) {
404+
NSNumber *_Nonnull)location clickedUrl : (NSString *)clickedUrl) {
403405
[_swiftAPI trackInAppClick:messageId location:location clickedUrl:clickedUrl];
404406
}
405407

406408
RCT_EXPORT_METHOD(trackInAppClose : (NSString *)messageId location : (
407-
NSNumber *)location source : (NSNumber *)source clickedUrl : (NSString *)
408-
clickedUrl) {
409+
NSNumber *_Nonnull)location source : (NSNumber *_Nonnull)
410+
source clickedUrl : (NSString *)clickedUrl) {
409411
[_swiftAPI trackInAppClose:messageId
410412
location:location
411413
source:source
412414
clickedUrl:clickedUrl];
413415
}
414416

415-
RCT_EXPORT_METHOD(inAppConsume : (NSString *)messageId location : (NSNumber *)
416-
location source : (NSNumber *)source) {
417+
RCT_EXPORT_METHOD(inAppConsume : (NSString *)messageId location : (
418+
NSNumber *_Nonnull)location source : (NSNumber *_Nonnull)source) {
417419
[_swiftAPI inAppConsume:messageId location:location source:source];
418420
}
419421

420422
RCT_EXPORT_METHOD(updateCart : (NSArray *)items) {
421423
[_swiftAPI updateCart:items];
422424
}
423425

424-
RCT_EXPORT_METHOD(trackPurchase : (NSNumber *)total items : (NSArray *)
426+
RCT_EXPORT_METHOD(trackPurchase : (NSNumber *_Nonnull)total items : (NSArray *)
425427
items dataFields : (NSDictionary *)dataFields) {
426428
[_swiftAPI trackPurchase:total items:items dataFields:dataFields];
427429
}
@@ -471,8 +473,8 @@ - (void)passAlongAuthToken:(NSString *)authToken {
471473
NSArray *)
472474
unsubscribedChannelIds unsubscribedMessageTypeIds : (NSArray *)
473475
unsubscribedMessageTypeIds subscribedMessageTypeIds : (NSArray *)
474-
subscribedMessageTypeIds campaignId : (NSNumber *)
475-
campaignId templateId : (NSNumber *)templateId) {
476+
subscribedMessageTypeIds campaignId : (NSNumber *_Nonnull)
477+
campaignId templateId : (NSNumber *_Nonnull)templateId) {
476478
[_swiftAPI updateSubscriptions:emailListIds
477479
unsubscribedChannelIds:unsubscribedChannelIds
478480
unsubscribedMessageTypeIds:unsubscribedMessageTypeIds

ios/RNIterableAPI/ReactIterableAPI.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ import React
163163
IterableAPI.attributionInfo = nil
164164
return
165165
}
166-
IterableAPI.attributionInfo = SerializationUtil.dictionaryToDecodable(
167166
guard let swiftDict = dict as? [AnyHashable: Any] else {
168167
IterableAPI.attributionInfo = nil
169168
return
@@ -319,7 +318,6 @@ import React
319318
@objc(updateUser:mergeNestedObjects:)
320319
public func updateUser(dataFields: NSDictionary, mergeNestedObjects: Bool) {
321320
ITBInfo()
322-
IterableAPI.updateUser(
323321
guard let fields = dataFields as? [AnyHashable: Any] else {
324322
ITBError("Could not cast dataFields to [AnyHashable: Any]")
325323
return
@@ -513,7 +511,6 @@ import React
513511
) {
514512
ITBInfo()
515513
let launchOptions = createLaunchOptions()
516-
let iterableConfig = IterableConfig.from(
517514
guard let configDictTyped = configDict as? [AnyHashable: Any] else {
518515
rejecter("E_INVALID_CONFIG", "configDict could not be cast to [AnyHashable: Any]", nil)
519516
return

0 commit comments

Comments
 (0)