Overview
Social authentication allows users to sign in to your app using their existing social media accounts. The Dynamic Swift SDK supports multiple providers including Apple, Google, Twitter, Discord, GitHub, Twitch, Facebook, and Farcaster.Prerequisites
1. Dynamic Dashboard Configuration
Before implementing social authentication, you must enable and configure the desired providers in your Dynamic dashboard:- Log in to Dynamic Dashboard
- Navigate to Log in and User Profile → Social
- Enable the providers you want to support
- Configure OAuth settings for each provider
2. Configure Deep Link URL
Register your app’s redirect URL in the Dynamic dashboard:- Go to Dynamic Dashboard
- Navigate to Security → Whitelist Mobile Deeplink
- Add your app’s deep link URL (e.g.,
myapp://auth/callback
) - Save the configuration
3. Info.plist Configuration
Add the following to yourInfo.plist
to ensure Safari authentication works properly:
Implementation
Get Available Providers
First, fetch the list of enabled providers for your environment:Implement Social Login
Provider Types
Complete Social Authentication Example
Here’s a complete example showing how to implement social authentication in a SwiftUI view:Best Practices
1. Deep Link URL Management
- Use a consistent deep link URL format
- Ensure the URL is whitelisted in your Dynamic dashboard
- Test deep link handling in your app
2. User Experience
- Show loading states during authentication
- Provide clear error messages
- Handle user cancellation gracefully
3. Security
- Never store sensitive authentication data
- Use secure network connections
- Implement proper session management
Troubleshooting
Callback Not Working
- Verify your app’s URL scheme is configured correctly in Dynamic dashboard
- Check that redirect URLs match in provider and Dynamic settings
- Ensure your
Info.plist
has the correct URL scheme configuration
Provider Not Showing
- Confirm provider is enabled in Dynamic dashboard
- Check that
getEnabledSocialProviders
is called successfully - Verify provider configuration in the respective developer console
Authentication Fails
- Check network connectivity
- Verify provider credentials in Dynamic dashboard
- Ensure deep link URL is correctly configured