11
11
import androidx .annotation .RestrictTo ;
12
12
import androidx .annotation .VisibleForTesting ;
13
13
14
- import com .iterable .iterableapi .util .DeviceInfoUtils ;
15
-
16
14
import org .json .JSONException ;
17
15
import org .json .JSONObject ;
18
16
@@ -40,8 +38,6 @@ public class IterableApi {
40
38
private IterableNotificationData _notificationData ;
41
39
private String _deviceId ;
42
40
private boolean _firstForegroundHandled ;
43
- private IterableHelper .SuccessHandler _setUserSuccessCallbackHandler ;
44
- private IterableHelper .FailureHandler _setUserFailureCallbackHandler ;
45
41
46
42
IterableApiClient apiClient = new IterableApiClient (new IterableApiAuthProvider ());
47
43
private @ Nullable IterableInAppManager inAppManager ;
@@ -73,15 +69,15 @@ public void execute(@Nullable String data) {
73
69
});
74
70
}
75
71
76
- public String getEmail () {
72
+ String getEmail () {
77
73
return _email ;
78
74
}
79
75
80
- public String getUserId () {
76
+ String getUserId () {
81
77
return _userId ;
82
78
}
83
79
84
- public String getAuthToken () {
80
+ String getAuthToken () {
85
81
return _authToken ;
86
82
}
87
83
@@ -319,8 +315,6 @@ private void completeUserLogin() {
319
315
320
316
if (config .autoPushRegistration ) {
321
317
registerForPush ();
322
- } else if (_setUserSuccessCallbackHandler != null ) {
323
- _setUserSuccessCallbackHandler .onSuccess (new JSONObject ()); // passing blank json object here as onSuccess is @Nonnull
324
318
}
325
319
326
320
getInAppManager ().syncInApp ();
@@ -353,7 +347,7 @@ private boolean isInitialized() {
353
347
354
348
private boolean checkSDKInitialization () {
355
349
if (!isInitialized ()) {
356
- IterableLogger .w (TAG , "Iterable SDK must be initialized with an API key and user email/userId before calling SDK methods" );
350
+ IterableLogger .e (TAG , "Iterable SDK must be initialized with an API key and user email/userId before calling SDK methods" );
357
351
return false ;
358
352
}
359
353
return true ;
@@ -392,13 +386,8 @@ private void retrieveEmailAndUserId() {
392
386
_email = prefs .getString (IterableConstants .SHARED_PREFS_EMAIL_KEY , null );
393
387
_userId = prefs .getString (IterableConstants .SHARED_PREFS_USERID_KEY , null );
394
388
_authToken = prefs .getString (IterableConstants .SHARED_PREFS_AUTH_TOKEN_KEY , null );
395
- if (config .authHandler != null ) {
396
- if (_authToken != null ) {
397
- getAuthManager ().queueExpirationRefresh (_authToken );
398
- } else {
399
- IterableLogger .d (TAG , "Auth token found as null. Scheduling token refresh in 10 seconds..." );
400
- getAuthManager ().scheduleAuthTokenRefresh (10000 );
401
- }
389
+ if (_authToken != null ) {
390
+ getAuthManager ().queueExpirationRefresh (_authToken );
402
391
}
403
392
} catch (Exception e ) {
404
393
IterableLogger .e (TAG , "Error while retrieving email/userId/authToken" , e );
@@ -514,7 +503,7 @@ protected void registerDeviceToken(@Nullable String email, @Nullable String user
514
503
IterableLogger .e (TAG , "registerDeviceToken: applicationName is null, check that pushIntegrationName is set in IterableConfig" );
515
504
}
516
505
517
- apiClient .registerDeviceToken (email , userId , authToken , applicationName , deviceToken , dataFields , deviceAttributes , _setUserSuccessCallbackHandler , _setUserFailureCallbackHandler );
506
+ apiClient .registerDeviceToken (email , userId , authToken , applicationName , deviceToken , dataFields , deviceAttributes );
518
507
}
519
508
//endregion
520
509
@@ -544,11 +533,8 @@ public static void initialize(@NonNull Context context, @NonNull String apiKey,
544
533
IterableActivityMonitor .getInstance ().addCallback (sharedInstance .activityMonitorListener );
545
534
546
535
if (sharedInstance .inAppManager == null ) {
547
- sharedInstance .inAppManager = new IterableInAppManager (
548
- sharedInstance ,
549
- sharedInstance .config .inAppHandler ,
550
- sharedInstance .config .inAppDisplayInterval ,
551
- sharedInstance .config .useInMemoryStorageForInApps );
536
+ sharedInstance .inAppManager = new IterableInAppManager (sharedInstance , sharedInstance .config .inAppHandler ,
537
+ sharedInstance .config .inAppDisplayInterval );
552
538
}
553
539
554
540
if (sharedInstance .embeddedManager == null ) {
@@ -557,17 +543,6 @@ public static void initialize(@NonNull Context context, @NonNull String apiKey,
557
543
558
544
loadLastSavedConfiguration (context );
559
545
IterablePushNotificationUtil .processPendingAction (context );
560
- if (DeviceInfoUtils .isFireTV (context .getPackageManager ())) {
561
- try {
562
- JSONObject dataFields = new JSONObject ();
563
- JSONObject deviceDetails = new JSONObject ();
564
- DeviceInfoUtils .populateDeviceDetails (deviceDetails , context , sharedInstance .getDeviceId ());
565
- dataFields .put (IterableConstants .KEY_FIRETV , deviceDetails );
566
- sharedInstance .apiClient .updateUser (dataFields , false );
567
- } catch (JSONException e ) {
568
- IterableLogger .e (TAG , "initialize: exception" , e );
569
- }
570
- }
571
546
}
572
547
573
548
public static void setContext (Context context ) {
@@ -637,18 +612,10 @@ public IterableAttributionInfo getAttributionInfo() {
637
612
}
638
613
639
614
public void setEmail (@ Nullable String email ) {
640
- setEmail (email , null , null , null );
641
- }
642
-
643
- public void setEmail (@ Nullable String email , @ Nullable IterableHelper .SuccessHandler successHandler , @ Nullable IterableHelper .FailureHandler failureHandler ) {
644
- setEmail (email , null , successHandler , failureHandler );
615
+ setEmail (email , null );
645
616
}
646
617
647
618
public void setEmail (@ Nullable String email , @ Nullable String authToken ) {
648
- setEmail (email , authToken , null , null );
649
- }
650
-
651
- public void setEmail (@ Nullable String email , @ Nullable String authToken , @ Nullable IterableHelper .SuccessHandler successHandler , @ Nullable IterableHelper .FailureHandler failureHandler ) {
652
619
//Only if passed in same non-null email
653
620
if (_email != null && _email .equals (email )) {
654
621
checkAndUpdateAuthToken (authToken );
@@ -663,26 +630,16 @@ public void setEmail(@Nullable String email, @Nullable String authToken, @Nullab
663
630
664
631
_email = email ;
665
632
_userId = null ;
666
- _setUserSuccessCallbackHandler = successHandler ;
667
- _setUserFailureCallbackHandler = failureHandler ;
668
633
storeAuthData ();
669
634
670
635
onLogin (authToken );
671
636
}
672
637
673
638
public void setUserId (@ Nullable String userId ) {
674
- setUserId (userId , null , null , null );
675
- }
676
-
677
- public void setUserId (@ Nullable String userId , @ Nullable IterableHelper .SuccessHandler successHandler , @ Nullable IterableHelper .FailureHandler failureHandler ) {
678
- setUserId (userId , null , successHandler , failureHandler );
639
+ setUserId (userId , null );
679
640
}
680
641
681
642
public void setUserId (@ Nullable String userId , @ Nullable String authToken ) {
682
- setUserId (userId , authToken , null , null );
683
- }
684
-
685
- public void setUserId (@ Nullable String userId , @ Nullable String authToken , @ Nullable IterableHelper .SuccessHandler successHandler , @ Nullable IterableHelper .FailureHandler failureHandler ) {
686
643
//If same non null userId is passed
687
644
if (_userId != null && _userId .equals (userId )) {
688
645
checkAndUpdateAuthToken (authToken );
@@ -697,8 +654,6 @@ public void setUserId(@Nullable String userId, @Nullable String authToken, @Null
697
654
698
655
_email = null ;
699
656
_userId = userId ;
700
- _setUserSuccessCallbackHandler = successHandler ;
701
- _setUserFailureCallbackHandler = failureHandler ;
702
657
storeAuthData ();
703
658
704
659
onLogin (authToken );
@@ -785,26 +740,7 @@ public void inAppConsume(@NonNull String messageId) {
785
740
IterableLogger .e (TAG , "inAppConsume: message is null" );
786
741
return ;
787
742
}
788
- inAppConsume (message , null , null , null , null );
789
- IterableLogger .printInfo ();
790
- }
791
-
792
- /**
793
- * Consumes an InApp message.
794
- * @param messageId
795
- * @param successHandler The callback which returns `success`.
796
- * @param failureHandler The callback which returns `failure`.
797
- */
798
- public void inAppConsume (@ NonNull String messageId , @ Nullable IterableHelper .SuccessHandler successHandler , @ Nullable IterableHelper .FailureHandler failureHandler ) {
799
- IterableInAppMessage message = getInAppManager ().getMessageById (messageId );
800
- if (message == null ) {
801
- IterableLogger .e (TAG , "inAppConsume: message is null" );
802
- if (failureHandler != null ) {
803
- failureHandler .onFailure ("inAppConsume: message is null" , null );
804
- }
805
- return ;
806
- }
807
- inAppConsume (message , null , null , successHandler , failureHandler );
743
+ inAppConsume (message , null , null );
808
744
IterableLogger .printInfo ();
809
745
}
810
746
@@ -821,25 +757,8 @@ public void inAppConsume(@NonNull IterableInAppMessage message, @Nullable Iterab
821
757
if (!checkSDKInitialization ()) {
822
758
return ;
823
759
}
824
- apiClient .inAppConsume (message , source , clickLocation , inboxSessionId , null , null );
825
- }
826
760
827
- /**
828
- * Tracks InApp delete.
829
- * This method from informs Iterable about inApp messages deleted with additional paramters.
830
- * Call this method from places where inApp deletion are invoked by user. The messages can be swiped to delete or can be deleted using the link to delete button.
831
- *
832
- * @param message message object
833
- * @param source An enum describing how the in App delete was triggered
834
- * @param clickLocation The module in which the action happened
835
- * @param successHandler The callback which returns `success`.
836
- * @param failureHandler The callback which returns `failure`.
837
- */
838
- public void inAppConsume (@ NonNull IterableInAppMessage message , @ Nullable IterableInAppDeleteActionType source , @ Nullable IterableInAppLocation clickLocation , @ Nullable IterableHelper .SuccessHandler successHandler , @ Nullable IterableHelper .FailureHandler failureHandler ) {
839
- if (!checkSDKInitialization ()) {
840
- return ;
841
- }
842
- apiClient .inAppConsume (message , source , clickLocation , inboxSessionId , successHandler , failureHandler );
761
+ apiClient .inAppConsume (message , source , clickLocation , inboxSessionId );
843
762
}
844
763
845
764
/**
0 commit comments