Skip to content

Commit f7a4ed9

Browse files
committed
add and integrate failure method for auth
1 parent a4fab3b commit f7a4ed9

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

swift-sdk/Internal/AuthManager.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,15 @@ class AuthManager: IterableAuthManagerProtocol {
9595
private func onAuthTokenReceived(retrievedAuthToken: String?, onSuccess: AuthTokenRetrievalHandler? = nil) {
9696
pendingAuth = false
9797

98+
guard let authToken = authToken else {
99+
delegate?.onTokenRegistrationFailed()
100+
101+
/// by default, schedule a refresh for 10s
102+
scheduleAuthTokenRefreshTimer(10)
103+
104+
return
105+
}
106+
98107
authToken = retrievedAuthToken
99108

100109
storeAuthToken()
@@ -110,6 +119,8 @@ class AuthManager: IterableAuthManagerProtocol {
110119
clearRefreshTimer()
111120

112121
guard let authToken = authToken, let expirationDate = AuthManager.decodeExpirationDateFromAuthToken(authToken) else {
122+
delegate?.onTokenRegistrationFailed()
123+
113124
/// schedule a default timer of 10 seconds if we fall into this case
114125
scheduleAuthTokenRefreshTimer(10)
115126

swift-sdk/IterableConfig.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ import Foundation
5555
/// The delegate for getting the authentication token
5656
@objc public protocol IterableAuthDelegate: AnyObject {
5757
@objc func onAuthTokenRequested(completion: @escaping AuthTokenRetrievalHandler)
58+
@objc func onTokenRegistrationFailed()
59+
}
60+
61+
extension IterableAuthDelegate {
62+
func onTokenRegistrationFailed() {
63+
64+
}
5865
}
5966

6067
/// Iterable Configuration Object. Use this when initializing the API.

0 commit comments

Comments
 (0)