Skip to content

Commit 3f449ae

Browse files
authored
Merge pull request #852 from Iterable/evan/MOB-9946
Evan/mob 9946
2 parents 57860d0 + 3083362 commit 3f449ae

File tree

1 file changed

+57
-25
lines changed

1 file changed

+57
-25
lines changed

swift-sdk/IterableAPI.swift

Lines changed: 57 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -288,12 +288,12 @@ import UIKit
288288
///
289289
/// - SeeAlso: IterableConfig
290290
public static func disableDeviceForCurrentUser() {
291-
implementation?.disableDeviceForCurrentUser()
291+
disableDeviceForCurrentUser(withOnSuccess: nil, onFailure: nil)
292292
}
293293

294294
/// Disable this device's token in Iterable, for all users on this device.
295295
public static func disableDeviceForAllUsers() {
296-
implementation?.disableDeviceForAllUsers()
296+
disableDeviceForAllUsers(withOnSuccess: nil, onFailure: nil)
297297
}
298298

299299
/// Disable this device's token in Iterable, for the current user, with custom completion blocks
@@ -304,7 +304,9 @@ import UIKit
304304
///
305305
/// - SeeAlso: OnSuccessHandler, OnFailureHandler
306306
public static func disableDeviceForCurrentUser(withOnSuccess onSuccess: OnSuccessHandler?, onFailure: OnFailureHandler?) {
307-
implementation?.disableDeviceForCurrentUser(withOnSuccess: onSuccess, onFailure: onFailure)
307+
guard let implementation, implementation.isSDKInitialized() else { return }
308+
309+
implementation.disableDeviceForCurrentUser(withOnSuccess: onSuccess, onFailure: onFailure)
308310
}
309311

310312
/// Disable this device's token in Iterable, for all users of this device, with custom completion blocks.
@@ -315,7 +317,9 @@ import UIKit
315317
///
316318
/// - SeeAlso: OnSuccessHandler, OnFailureHandler
317319
public static func disableDeviceForAllUsers(withOnSuccess onSuccess: OnSuccessHandler?, onFailure: OnFailureHandler?) {
318-
implementation?.disableDeviceForAllUsers(withOnSuccess: onSuccess, onFailure: onFailure)
320+
guard let implementation, implementation.isSDKInitialized() else { return }
321+
322+
implementation.disableDeviceForAllUsers(withOnSuccess: onSuccess, onFailure: onFailure)
319323
}
320324

321325
/// Updates the available user fields
@@ -332,9 +336,8 @@ import UIKit
332336
mergeNestedObjects: Bool,
333337
onSuccess: OnSuccessHandler? = nil,
334338
onFailure: OnFailureHandler? = nil) {
335-
guard let implementation, implementation.isSDKInitialized() else { return }
336339

337-
implementation.updateUser(dataFields,
340+
implementation?.updateUser(dataFields,
338341
mergeNestedObjects: mergeNestedObjects,
339342
onSuccess: onSuccess,
340343
onFailure: onFailure)
@@ -413,9 +416,8 @@ import UIKit
413416
public static func updateCart(items: [CommerceItem],
414417
onSuccess: OnSuccessHandler?,
415418
onFailure: OnFailureHandler?) {
416-
guard let implementation, implementation.isSDKInitialized() else { return }
417419

418-
implementation.updateCart(items: items, onSuccess: onSuccess, onFailure: onFailure)
420+
implementation?.updateCart(items: items, onSuccess: onSuccess, onFailure: onFailure)
419421
}
420422

421423
/// Tracks a purchase
@@ -506,10 +508,8 @@ import UIKit
506508
templateId: NSNumber?,
507509
onSuccess: OnSuccessHandler?,
508510
onFailure: OnFailureHandler?) {
509-
510-
guard let implementation, implementation.isSDKInitialized() else { return }
511-
512-
implementation.trackPurchase(withTotal,
511+
512+
implementation?.trackPurchase(withTotal,
513513
items: items,
514514
dataFields: dataFields,
515515
campaignId: campaignId,
@@ -525,7 +525,12 @@ import UIKit
525525
/// - userInfo: the `userInfo` parameter from the push notification payload
526526
@objc(trackPushOpen:)
527527
public static func track(pushOpen userInfo: [AnyHashable: Any]) {
528-
implementation?.trackPushOpen(userInfo)
528+
track(
529+
pushOpen: userInfo,
530+
dataFields: nil,
531+
onSuccess: nil,
532+
onFailure: nil
533+
)
529534
}
530535

531536
/// Tracks a `pushOpen` event with a push notification and optional additional data
@@ -535,7 +540,12 @@ import UIKit
535540
/// - dataFields: A `Dictionary` containing any additional information to save along with the event
536541
@objc(trackPushOpen:dataFields:)
537542
public static func track(pushOpen userInfo: [AnyHashable: Any], dataFields: [AnyHashable: Any]?) {
538-
implementation?.trackPushOpen(userInfo, dataFields: dataFields)
543+
track(
544+
pushOpen: userInfo,
545+
dataFields: dataFields,
546+
onSuccess: nil,
547+
onFailure: nil
548+
)
539549
}
540550

541551
/// Tracks a `pushOpen` event with a push notification, optional additional data, and custom completion blocks
@@ -552,7 +562,9 @@ import UIKit
552562
dataFields: [AnyHashable: Any]?,
553563
onSuccess: OnSuccessHandler?,
554564
onFailure: OnFailureHandler?) {
555-
implementation?.trackPushOpen(userInfo,
565+
guard let implementation, implementation.isSDKInitialized() else { return }
566+
567+
implementation.trackPushOpen(userInfo,
556568
dataFields: dataFields,
557569
onSuccess: onSuccess,
558570
onFailure: onFailure)
@@ -576,11 +588,15 @@ import UIKit
576588
messageId: String,
577589
appAlreadyRunning: Bool,
578590
dataFields: [AnyHashable: Any]?) {
579-
implementation?.trackPushOpen(campaignId,
580-
templateId: templateId,
581-
messageId: messageId,
582-
appAlreadyRunning: appAlreadyRunning,
583-
dataFields: dataFields)
591+
track(
592+
pushOpen: campaignId,
593+
templateId: templateId,
594+
messageId: messageId,
595+
appAlreadyRunning: appAlreadyRunning,
596+
dataFields: dataFields,
597+
onSuccess: nil,
598+
onFailure: nil
599+
)
584600
}
585601

586602
/// Tracks a `pushOpen` event for the specified campaign and template IDs, whether the app was already
@@ -605,7 +621,9 @@ import UIKit
605621
dataFields: [AnyHashable: Any]?,
606622
onSuccess: OnSuccessHandler?,
607623
onFailure: OnFailureHandler?) {
608-
implementation?.trackPushOpen(campaignId,
624+
guard let implementation, implementation.isSDKInitialized() else { return }
625+
626+
implementation.trackPushOpen(campaignId,
609627
templateId: templateId,
610628
messageId: messageId,
611629
appAlreadyRunning: appAlreadyRunning,
@@ -622,7 +640,12 @@ import UIKit
622640
/// - Remark: Pass in the custom event data.
623641
@objc(track:)
624642
public static func track(event eventName: String) {
625-
implementation?.track(eventName)
643+
track(
644+
event: eventName,
645+
dataFields: nil,
646+
onSuccess: nil,
647+
onFailure: nil
648+
)
626649
}
627650

628651
/// Tracks a custom event
@@ -634,7 +657,12 @@ import UIKit
634657
/// - Remark: Pass in the custom event data.
635658
@objc(track:dataFields:)
636659
public static func track(event eventName: String, dataFields: [AnyHashable: Any]?) {
637-
implementation?.track(eventName, dataFields: dataFields)
660+
track(
661+
event: eventName,
662+
dataFields: dataFields,
663+
onSuccess: nil,
664+
onFailure: nil
665+
)
638666
}
639667

640668
/// Tracks a custom event
@@ -691,7 +719,9 @@ import UIKit
691719
/// - embeddedSession: the embedded session data type to track
692720
@objc(embeddedSession:)
693721
public static func track(embeddedSession: IterableEmbeddedSession) {
694-
implementation?.track(embeddedSession: embeddedSession)
722+
guard let implementation, implementation.isSDKInitialized() else { return }
723+
724+
implementation.track(embeddedSession: embeddedSession)
695725
}
696726

697727
@objc(embeddedMessageClick:buttonIdentifier:clickedUrl:)
@@ -814,7 +844,9 @@ import UIKit
814844
/// - inboxSession: the inbox session data type to track
815845
@objc(trackInboxSession:)
816846
public static func track(inboxSession: IterableInboxSession) {
817-
implementation?.track(inboxSession: inboxSession)
847+
guard let implementation, implementation.isSDKInitialized() else { return }
848+
849+
implementation.track(inboxSession: inboxSession)
818850
}
819851

820852
// MARK: - Private/Internal

0 commit comments

Comments
 (0)