MoEngageAuthenticationError
@objc
public class MoEngageAuthenticationError : NSObjectBase Authentication Error class that encapsulates detailed error information.
This class represents authentication errors that occur during network requests in the MoEngage SDK. It provides comprehensive error details including specific error codes, human-readable messages, and account metadata for debugging and error handling purposes.
Error Handling
Authentication errors can occur due to various reasons such as token expiration, invalid signatures, malformed tokens, or network issues. This class provides structured error information to help developers handle these scenarios appropriately.
- 
                  
                  Account metadata containing workspace and instance information. This metadata provides context about which MoEngage account and SDK instance the error is associated with. Useful for multi-workspace applications. Contents- Workspace ID (App ID)
 DeclarationSwift @objc public let accountMeta: MoEngageAccountMeta
- 
                  
                  Computed property for accessing the error details. DeclarationSwift @objc public var details: Details { get }
- 
                  
                  Base authentication error details class. This class serves as the base for all authentication error details. Specific authentication types should subclass this to provide additional context. See moreDeclarationSwift @objc(MoEngageAuthenticationErrorDetails) public class Details : NSObject
- 
                  
                  Protocol for receiving authentication error notifications. Implement this protocol to receive callbacks when authentication errors occur during network requests. The listener provides a way to handle authentication failures and implement appropriate recovery strategies. Implementation GuidelinesThread Safety- Listener methods are called serially
- Ensure your implementation is thread-safe
- Avoid blocking operations in callback methods
 Error Handling- Implement specific handling for different error codes
- Consider user experience when handling errors
- Log errors for debugging and analytics
 Recovery Strategies- Implement token refresh for expiration errors
- Provide re-authentication for signature failures
- Handle missing tokens by requesting new ones
 Usage Exampleclass AuthErrorHandler: MoEngageAuthenticationError.Listener { func onError(_ error: MoEngageAuthenticationError) { // Log error for analytics Analytics.logAuthError(error.code.rawValue, error.message) // Handle JWT-specific errors if let jwtError = error as? MoEngageJwtAuthenticationError { handleJwtError(jwtError) } } private func handleJwtError(_ error: MoEngageJwtAuthenticationError) { // Handle based on specific JWT error code switch error.details.code { case .timeConstraintFailure: handleTokenExpiration(error) case .invalidSignature: handleSignatureFailure(error) case .tokenNotAvailable: handleMissingToken(error) default: handleGenericError(error) } } }RegistrationRegister your listener using the SDK’s registration methods: let errorHandler = AuthErrorHandler() MoEngageSDKCore.sharedInstance.registerAuthenticationListener(errorHandler)Lifecycle Management- Listeners are held with strong references
- Ensure proper cleanup when no longer needed
- Consider using weak references in your implementation to avoid retain cycles
 DeclarationSwift @objc(MoEngageAuthenticationErrorListener) public protocol Listener
