File tree 2 files changed +17
-3
lines changed
iterableapi/src/main/java/com/iterable/iterableapi
2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -347,8 +347,13 @@ private void retrieveEmailAndUserId() {
347
347
_email = prefs .getString (IterableConstants .SHARED_PREFS_EMAIL_KEY , null );
348
348
_userId = prefs .getString (IterableConstants .SHARED_PREFS_USERID_KEY , null );
349
349
_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
+ }
352
357
}
353
358
} catch (Exception e ) {
354
359
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 {
49
49
public void onSuccess (String authToken ) {
50
50
if (authToken != null ) {
51
51
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 ;
52
58
}
53
59
IterableApi .getInstance ().setAuthToken (authToken );
54
60
pendingAuth = false ;
@@ -88,6 +94,9 @@ public void queueExpirationRefresh(String encodedJWT) {
88
94
}
89
95
} catch (Exception e ) {
90
96
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 );
91
100
}
92
101
}
93
102
@@ -102,7 +111,7 @@ void reSyncAuth() {
102
111
}
103
112
}
104
113
105
- private void scheduleAuthTokenRefresh (long timeDuration ) {
114
+ void scheduleAuthTokenRefresh (long timeDuration ) {
106
115
timer = new Timer (true );
107
116
try {
108
117
timer .schedule (new TimerTask () {
You can’t perform that action at this time.
0 commit comments