The Dynamic Swift SDK provides multiple authentication methods including Email OTP, SMS OTP, and Social Login. This guide covers how to implement each authentication method in your iOS application.
Social authentication allows users to sign in using their existing social media accounts including Apple, Google, Twitter, Discord, GitHub, and Twitch.For detailed setup instructions, provider configuration, and implementation examples, see the Social Authentication Guide.
// Get current authenticated userif let currentUser = dynamicClient.user { print("User is authenticated: \(currentUser.id)")} else { print("User is not authenticated")}
The OTPVerification object is returned when sending an OTP and must be stored to verify the OTP later:
Copy
Ask AI
public struct OTPVerification { public let email: String? // Email address (for email OTP) public let phoneNumber: String? // Phone number (for SMS OTP) public let phoneCountryCode: String? // Country code (for SMS OTP) public let isoCountryCode: String? // ISO country code (for SMS OTP) public let verificationUUID: String // Unique ID for this verification}
The SdkUser object represents an authenticated user:
Copy
Ask AI
public struct SdkUser { public let id: String // User's unique ID public let email: String? // User's email public let phoneNumber: String? // User's phone number // ... other user properties}