@@ -126,10 +126,10 @@ import UIKit
126
126
callback ? ( false )
127
127
}
128
128
129
- if let _implementation = implementation, config. enableAnonTracking, !_implementation . isEitherUserIdOrEmailSet ( ) , _implementation . getAnonymousUsageTracked ( ) {
129
+ if let implementation, config. enableAnonTracking, !implementation . isSDKInitialized ( ) , implementation . getAnonymousUsageTracked ( ) {
130
130
ITBInfo ( " AUT ENABLED AND CONSENT GIVEN - Criteria fetched " )
131
- _implementation . anonymousUserManager. getAnonCriteria ( )
132
- _implementation . anonymousUserManager. updateAnonSession ( )
131
+ implementation . anonymousUserManager. getAnonCriteria ( )
132
+ implementation . anonymousUserManager. updateAnonSession ( )
133
133
}
134
134
}
135
135
@@ -250,7 +250,7 @@ import UIKit
250
250
/// - SeeAlso: IterableConfig
251
251
@objc ( registerToken: )
252
252
public static func register( token: Data ) {
253
- implementation ? . register ( token: token)
253
+ register ( token: token, onSuccess : nil , onFailure : nil )
254
254
}
255
255
256
256
/// Register this device's token with Iterable
@@ -268,7 +268,8 @@ import UIKit
268
268
/// - SeeAlso: IterableConfig, OnSuccessHandler, OnFailureHandler
269
269
@objc ( registerToken: onSuccess: OnFailure: )
270
270
public static func register( token: Data , onSuccess: OnSuccessHandler ? = nil , onFailure: OnFailureHandler ? = nil ) {
271
- implementation? . register ( token: token, onSuccess: onSuccess, onFailure: onFailure)
271
+ guard let implementation, implementation. isSDKInitialized ( ) else { return }
272
+ implementation. register ( token: token, onSuccess: onSuccess, onFailure: onFailure)
272
273
}
273
274
274
275
@objc ( pauseAuthRetries: )
@@ -331,10 +332,12 @@ import UIKit
331
332
mergeNestedObjects: Bool ,
332
333
onSuccess: OnSuccessHandler ? = nil ,
333
334
onFailure: OnFailureHandler ? = nil ) {
334
- implementation? . updateUser ( dataFields,
335
- mergeNestedObjects: mergeNestedObjects,
336
- onSuccess: onSuccess,
337
- onFailure: onFailure)
335
+ guard let implementation, implementation. isSDKInitialized ( ) else { return }
336
+
337
+ implementation. updateUser ( dataFields,
338
+ mergeNestedObjects: mergeNestedObjects,
339
+ onSuccess: onSuccess,
340
+ onFailure: onFailure)
338
341
}
339
342
340
343
/// Updates the current user's email
@@ -348,8 +351,17 @@ import UIKit
348
351
///
349
352
/// - SeeAlso: OnSuccessHandler, OnFailureHandler
350
353
@objc ( updateEmail: onSuccess: onFailure: )
351
- public static func updateEmail( _ newEmail: String , onSuccess: OnSuccessHandler ? , onFailure: OnFailureHandler ? ) {
352
- implementation? . updateEmail ( newEmail, onSuccess: onSuccess, onFailure: onFailure)
354
+ public static func updateEmail(
355
+ _ newEmail: String ,
356
+ onSuccess: OnSuccessHandler ? ,
357
+ onFailure: OnFailureHandler ?
358
+ ) {
359
+ updateEmail (
360
+ newEmail,
361
+ withToken: nil ,
362
+ onSuccess: onSuccess,
363
+ onFailure: onFailure
364
+ )
353
365
}
354
366
355
367
/// Updates the current user's email, and set the new authentication token
@@ -365,10 +377,17 @@ import UIKit
365
377
/// - SeeAlso: OnSuccessHandler, OnFailureHandler
366
378
@objc ( updateEmail: withToken: onSuccess: onFailure: )
367
379
public static func updateEmail( _ newEmail: String ,
368
- withToken token: String ,
380
+ withToken token: String ? = nil ,
369
381
onSuccess: OnSuccessHandler ? ,
370
382
onFailure: OnFailureHandler ? ) {
371
- implementation? . updateEmail ( newEmail, withToken: token, onSuccess: onSuccess, onFailure: onFailure)
383
+ guard let implementation, implementation. isSDKInitialized ( ) else { return }
384
+
385
+ implementation. updateEmail (
386
+ newEmail,
387
+ withToken: token,
388
+ onSuccess: onSuccess,
389
+ onFailure: onFailure
390
+ )
372
391
}
373
392
374
393
/// Tracks what's in the shopping cart (or equivalent) at this point in time
@@ -379,7 +398,7 @@ import UIKit
379
398
/// - SeeAlso: CommerceItem
380
399
@objc ( updateCart: )
381
400
public static func updateCart( items: [ CommerceItem ] ) {
382
- implementation ? . updateCart ( items: items)
401
+ updateCart ( items: items, onSuccess : nil , onFailure : nil )
383
402
}
384
403
385
404
/// Tracks what's in the shopping cart (or equivalent) at this point in time
@@ -394,7 +413,9 @@ import UIKit
394
413
public static func updateCart( items: [ CommerceItem ] ,
395
414
onSuccess: OnSuccessHandler ? ,
396
415
onFailure: OnFailureHandler ? ) {
397
- implementation? . updateCart ( items: items, onSuccess: onSuccess, onFailure: onFailure)
416
+ guard let implementation, implementation. isSDKInitialized ( ) else { return }
417
+
418
+ implementation. updateCart ( items: items, onSuccess: onSuccess, onFailure: onFailure)
398
419
}
399
420
400
421
/// Tracks a purchase
@@ -406,7 +427,15 @@ import UIKit
406
427
/// - SeeAlso: CommerceItem
407
428
@objc ( trackPurchase: items: )
408
429
public static func track( purchase withTotal: NSNumber , items: [ CommerceItem ] ) {
409
- implementation? . trackPurchase ( withTotal, items: items)
430
+ track (
431
+ purchase: withTotal,
432
+ items: items,
433
+ dataFields: nil ,
434
+ campaignId: nil ,
435
+ templateId: nil ,
436
+ onSuccess: nil ,
437
+ onFailure: nil
438
+ )
410
439
}
411
440
412
441
/// Tracks a purchase with additional data
@@ -419,7 +448,15 @@ import UIKit
419
448
/// - SeeAlso: CommerceItem
420
449
@objc ( trackPurchase: items: dataFields: )
421
450
public static func track( purchase withTotal: NSNumber , items: [ CommerceItem ] , dataFields: [ AnyHashable : Any ] ? ) {
422
- implementation? . trackPurchase ( withTotal, items: items, dataFields: dataFields)
451
+ track (
452
+ purchase: withTotal,
453
+ items: items,
454
+ dataFields: dataFields,
455
+ campaignId: nil ,
456
+ templateId: nil ,
457
+ onSuccess: nil ,
458
+ onFailure: nil
459
+ )
423
460
}
424
461
425
462
/// Tracks a purchase with additional data and custom completion blocks.
@@ -438,11 +475,15 @@ import UIKit
438
475
dataFields: [ AnyHashable : Any ] ? ,
439
476
onSuccess: OnSuccessHandler ? ,
440
477
onFailure: OnFailureHandler ? ) {
441
- implementation? . trackPurchase ( withTotal,
442
- items: items,
443
- dataFields: dataFields,
444
- onSuccess: onSuccess,
445
- onFailure: onFailure)
478
+ track (
479
+ purchase: withTotal,
480
+ items: items,
481
+ dataFields: dataFields,
482
+ campaignId: nil ,
483
+ templateId: nil ,
484
+ onSuccess: onSuccess,
485
+ onFailure: onFailure
486
+ )
446
487
}
447
488
448
489
/// Tracks a purchase with additional data and custom completion blocks.
@@ -465,13 +506,16 @@ import UIKit
465
506
templateId: NSNumber ? ,
466
507
onSuccess: OnSuccessHandler ? ,
467
508
onFailure: OnFailureHandler ? ) {
468
- implementation? . trackPurchase ( withTotal,
469
- items: items,
470
- dataFields: dataFields,
471
- campaignId: campaignId,
472
- templateId: templateId,
473
- onSuccess: onSuccess,
474
- onFailure: onFailure)
509
+
510
+ guard let implementation, implementation. isSDKInitialized ( ) else { return }
511
+
512
+ implementation. trackPurchase ( withTotal,
513
+ items: items,
514
+ dataFields: dataFields,
515
+ campaignId: campaignId,
516
+ templateId: templateId,
517
+ onSuccess: onSuccess,
518
+ onFailure: onFailure)
475
519
}
476
520
477
521
@@ -628,7 +672,9 @@ import UIKit
628
672
subscribedMessageTypeIds: [ NSNumber ] ? ,
629
673
campaignId: NSNumber ? ,
630
674
templateId: NSNumber ? ) {
631
- implementation? . updateSubscriptions ( emailListIds,
675
+ guard let implementation, implementation. isSDKInitialized ( ) else { return }
676
+
677
+ implementation. updateSubscriptions ( emailListIds,
632
678
unsubscribedChannelIds: unsubscribedChannelIds,
633
679
unsubscribedMessageTypeIds: unsubscribedMessageTypeIds,
634
680
subscribedMessageTypeIds: subscribedMessageTypeIds,
@@ -650,12 +696,16 @@ import UIKit
650
696
651
697
@objc ( embeddedMessageClick: buttonIdentifier: clickedUrl: )
652
698
public static func track( embeddedMessageClick: IterableEmbeddedMessage , buttonIdentifier: String ? , clickedUrl: String ) {
653
- implementation? . track ( embeddedMessageClick: embeddedMessageClick, buttonIdentifier: buttonIdentifier, clickedUrl: clickedUrl)
699
+ guard let implementation, implementation. isSDKInitialized ( ) else { return }
700
+
701
+ implementation. track ( embeddedMessageClick: embeddedMessageClick, buttonIdentifier: buttonIdentifier, clickedUrl: clickedUrl)
654
702
}
655
703
656
704
@objc ( embeddedMessageReceived: )
657
705
public static func track( embeddedMessageReceived: IterableEmbeddedMessage ) {
658
- implementation? . track ( embeddedMessageReceived: embeddedMessageReceived)
706
+ guard let implementation, implementation. isSDKInitialized ( ) else { return }
707
+
708
+ implementation. track ( embeddedMessageReceived: embeddedMessageReceived)
659
709
}
660
710
661
711
// MARK: In-App Notifications
@@ -672,7 +722,9 @@ import UIKit
672
722
/// - SeeAlso: IterableInAppDelegate
673
723
@objc ( trackInAppOpen: location: )
674
724
public static func track( inAppOpen message: IterableInAppMessage , location: InAppLocation = . inApp) {
675
- implementation? . trackInAppOpen ( message, location: location)
725
+ guard let implementation, implementation. isSDKInitialized ( ) else { return }
726
+
727
+ implementation. trackInAppOpen ( message, location: location)
676
728
}
677
729
678
730
/// Tracks an `InAppClick` event
@@ -686,7 +738,9 @@ import UIKit
686
738
/// - clickedUrl: The URL of the button or link that was clicked
687
739
@objc ( trackInAppClick: location: clickedUrl: )
688
740
public static func track( inAppClick message: IterableInAppMessage , location: InAppLocation = . inApp, clickedUrl: String ) {
689
- implementation? . trackInAppClick ( message, location: location, clickedUrl: clickedUrl)
741
+ guard let implementation, implementation. isSDKInitialized ( ) else { return }
742
+
743
+ implementation. trackInAppClick ( message, location: location, clickedUrl: clickedUrl)
690
744
}
691
745
692
746
/// Tracks an `InAppClose` event
@@ -696,7 +750,9 @@ import UIKit
696
750
/// - clickedUrl: The url that was clicked to close the in-app. It will be `nil` when the message is closed by clicking `back`.
697
751
@objc ( trackInAppClose: clickedUrl: )
698
752
public static func track( inAppClose message: IterableInAppMessage , clickedUrl: String ? ) {
699
- implementation? . trackInAppClose ( message, clickedUrl: clickedUrl)
753
+ guard let implementation, implementation. isSDKInitialized ( ) else { return }
754
+
755
+ implementation. trackInAppClose ( message, clickedUrl: clickedUrl)
700
756
}
701
757
702
758
/// Tracks an `InAppClose` event
@@ -707,7 +763,9 @@ import UIKit
707
763
/// - clickedUrl: The URL that was clicked to close the in-app. It will be `nil` when the message is closed by clicking `back`.
708
764
@objc ( trackInAppClose: location: clickedUrl: )
709
765
public static func track( inAppClose message: IterableInAppMessage , location: InAppLocation , clickedUrl: String ? ) {
710
- implementation? . trackInAppClose ( message, location: location, clickedUrl: clickedUrl)
766
+ guard let implementation, implementation. isSDKInitialized ( ) else { return }
767
+
768
+ implementation. trackInAppClose ( message, location: location, clickedUrl: clickedUrl)
711
769
}
712
770
713
771
/// Tracks an `InAppClose` event
@@ -719,7 +777,9 @@ import UIKit
719
777
/// - clickedUrl: The url that was clicked to close the in-app. It will be `nil` when the message is closed by clicking `back`.
720
778
@objc ( trackInAppClose: location: source: clickedUrl: )
721
779
public static func track( inAppClose message: IterableInAppMessage , location: InAppLocation , source: InAppCloseSource , clickedUrl: String ? ) {
722
- implementation? . trackInAppClose ( message, location: location, source: source, clickedUrl: clickedUrl)
780
+ guard let implementation, implementation. isSDKInitialized ( ) else { return }
781
+
782
+ implementation. trackInAppClose ( message, location: location, source: source, clickedUrl: clickedUrl)
723
783
}
724
784
725
785
/// Consumes the notification and removes it from the list of in-app messages
@@ -729,7 +789,9 @@ import UIKit
729
789
/// - location: The location from where this message was shown. `inbox` or `inApp`.
730
790
@objc ( inAppConsume: location: )
731
791
public static func inAppConsume( message: IterableInAppMessage , location: InAppLocation = . inApp) {
732
- implementation? . inAppConsume ( message: message, location: location)
792
+ guard let implementation, implementation. isSDKInitialized ( ) else { return }
793
+
794
+ implementation. inAppConsume ( message: message, location: location)
733
795
}
734
796
735
797
/// Consumes the notification and removes it from the list of in-app messages
@@ -740,7 +802,9 @@ import UIKit
740
802
/// - source: The source of deletion `inboxSwipe` or `deleteButton`.
741
803
@objc ( inAppConsume: location: source: )
742
804
public static func inAppConsume( message: IterableInAppMessage , location: InAppLocation = . inApp, source: InAppDeleteSource ) {
743
- implementation? . inAppConsume ( message: message, location: location, source: source)
805
+ guard let implementation, implementation. isSDKInitialized ( ) else { return }
806
+
807
+ implementation. inAppConsume ( message: message, location: location, source: source)
744
808
}
745
809
746
810
/// Tracks analytics data from a session of using an inbox UI
0 commit comments