@@ -731,7 +731,73 @@ let networkStatus = WarplySDK.shared.getNetworkStatus()
## 🔐 Authentication
### User Login
### DEI Login (Email-based Authentication) 🆕
The DEI login method provides email-based authentication for DEI platform users. This method automatically handles JWT token extraction and secure storage.
```swift
// Completion handler approach
WarplySDK.shared.deiLogin(
email: "user@example.com",
completion: { response in
if let response = response, response.getStatus == 1 {
print("DEI login successful")
// User is now authenticated - proceed with authenticated operations
// Tokens are automatically stored and managed by the SDK
} else {
print("DEI login failed")
}
},
failureCallback: { errorCode in
print("DEI login failed with error: \(errorCode)")
// Handle specific error codes
switch errorCode {
case 401:
print("Invalid email or authentication failed")
case -1009:
print("No internet connection")
default:
print("Unknown error occurred")
}
}
)
// Async/await approach (Recommended)
Task {
do {
let response = try await WarplySDK.shared.deiLogin(email: "user@example.com")
if response.getStatus == 1 {
print("DEI login successful")
// User is now authenticated - proceed with authenticated operations
// Access other authenticated endpoints like getCoupons, getProfile, etc.