Integrate Facebook & Google SDKs
This section provides detailed steps for integrating Google and Facebook login functionality into your application using the Google SDK and Facebook SDK. This guide will walk you through the process of incorporating authentication via Google and Facebook, enabling users to seamlessly log in using their existing accounts. The integration covers both the setup of the respective SDKs and the necessary configuration steps for a smooth login experience.
Prerequisites
Before you proceed with integrating Google and Facebook login using the Google SDK and Facebook SDK, make sure to complete the integration steps from the OTPless iOS Headless SDK Documentation.
The supported version for the OTPless SDK is 2.2.8. This version is essential to ensure compatibility with the login integrations.
Once you’ve completed the integration from the link above, you can continue with the following steps to incorporate Google and Facebook login into your app.
Add SDK Dependency
SDK can be installed via both Cocoapods and Swift Package Manager.
Cocoapods
- Open your app’s project file
.xcodeproj
. - Add the following line into the dependencies section of your project’s
Podfile
:
Swift Package Manager
- In Xcode, click File > Swift Packages > Add Package Dependency.
- In the dialog that appears, enter the repository URL: https://github.com/otpless-tech/Otpless-iOS-SDK.git.
- Select the dependency rule as
exact version
and use the version2.2.8
.
- Note: If you are using SPM for SDK installation, both GoogleSupport and FacebookSupport are installed.
Choose your platform type to initiate login:
Configuration for Google SDK Login
Update the Info.plist
File
To enable Google SDK login in your app, you’ll need to add the necessary configurations in your Info.plist
file.
- Add your
GIDClientID
: This is the Google Client ID that you will obtain from the Google Developer Console.
Configure URL Schemes
Google sign-in requires a URL scheme that ensures the app can handle the redirect after authentication. This URL scheme should be based on the reversed Google Client ID.
- Add the
CFBundleURLTypes
configuration:
Make sure to replace YOUR_GOOGLE_CLIENT_ID
with the actual ClientID
provided by Google and DOT_REVERSED_GOOGLE_CLIENT_ID
with the reversed version of your ClientID
.
This setup ensures that your app can integrate smoothly with Google’s login system and handle redirects after authentication.
AppDelegate Configuration
Handles OTPless deeplinks when the app is opened via a URL.
Request
To initiate an google login, set the channel type as GOOGLE_SDK
.
Note: Provide Google Client ID
For proper functioning of Google login in your application, you need to provide the ClientId
and Client Secret
of the credentials created on the Google Cloud Console.
Please ensure that the ClientId
and Client Secret
associated with your application is provided to OTPless for seamless integration and authentication functionality. This is crucial for the authentication process to work correctly.
Was this page helpful?