File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed
iterableapi/src/main/java/com/iterable/iterableapi Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -347,8 +347,13 @@ private void retrieveEmailAndUserId() {
347347 _email = prefs .getString (IterableConstants .SHARED_PREFS_EMAIL_KEY , null );
348348 _userId = prefs .getString (IterableConstants .SHARED_PREFS_USERID_KEY , null );
349349 _authToken = prefs .getString (IterableConstants .SHARED_PREFS_AUTH_TOKEN_KEY , null );
350- if (_authToken != null ) {
351- getAuthManager ().queueExpirationRefresh (_authToken );
350+ if (config .authHandler != null ) {
351+ if (_authToken != null ) {
352+ getAuthManager ().queueExpirationRefresh (_authToken );
353+ } else {
354+ IterableLogger .d (TAG , "Auth token found as null. Scheduling token refresh in 10 seconds..." );
355+ getAuthManager ().scheduleAuthTokenRefresh (10000 );
356+ }
352357 }
353358 } catch (Exception e ) {
354359 IterableLogger .e (TAG , "Error while retrieving email/userId/authToken" , e );
Original file line number Diff line number Diff line change @@ -49,6 +49,12 @@ public String call() throws Exception {
4949 public void onSuccess (String authToken ) {
5050 if (authToken != null ) {
5151 queueExpirationRefresh (authToken );
52+ } else {
53+ IterableLogger .w (TAG , "Auth token received as null. Calling the handler in 10 seconds" );
54+ //TODO: Make this time configurable and in sync with SDK initialization flow for auth null scenario
55+ scheduleAuthTokenRefresh (10000 );
56+ authHandler .onTokenRegistrationFailed (new Throwable ("Auth token null" ));
57+ return ;
5258 }
5359 IterableApi .getInstance ().setAuthToken (authToken );
5460 pendingAuth = false ;
@@ -88,6 +94,9 @@ public void queueExpirationRefresh(String encodedJWT) {
8894 }
8995 } catch (Exception e ) {
9096 IterableLogger .e (TAG , "Error while parsing JWT for the expiration" , e );
97+ authHandler .onTokenRegistrationFailed (new Throwable ("Auth token decode failure. Scheduling auth token refresh in 10 seconds..." ));
98+ //TODO: Sync with configured time duration once feature is available.
99+ scheduleAuthTokenRefresh (10000 );
91100 }
92101 }
93102
@@ -102,7 +111,7 @@ void reSyncAuth() {
102111 }
103112 }
104113
105- private void scheduleAuthTokenRefresh (long timeDuration ) {
114+ void scheduleAuthTokenRefresh (long timeDuration ) {
106115 timer = new Timer (true );
107116 try {
108117 timer .schedule (new TimerTask () {
You can’t perform that action at this time.
0 commit comments