Overseas users with < mobile number-verification code > have low login intentions. Therefore, access three-party login to improve user login rate. Third-party logins for overseas applications generally refer to authorized logins from Google and Facebook.
Google login
Google Sign-In for Android has the following requirements:
- A compatible Android device that runs Android 4.1 or newer and includes the Google Play Store or an emulator with an AVD that runs the Google APIs platform based on Android 4.2.2 or newer and has Google Play services version 15.0.0 or newer.
- The latest version of the Android SDK, including the SDK Tools component. The SDK is available from the Android SDK Manager in Android Studio.
- A project configured to compile against Android 4.1 (Jelly Bean) or newer.
The above requirements are from the Google Identity website, which describes the requirements for devices and projects that are connected to Google Sign:
1. Emulators that are compatible with Android version 4.1 or higher and include Google Play Store, or that run on Google API platform version 4.2.2 or higher and Google Service version 15.0.0 or higher
2. Latest version of Android SDK
3.compileSdkVersion is 4.1 or later
configuration
The code access fee requires some developer configuration, which can be configured in Firebase project Settings if your project is connected to Firebase, or in Google Identity if it is not. If the SHA1 fingerprint has been added to the project, skip the following steps.
1. Generate SHA1 fingerprints and add them to the project. In Android Studio, click Gradle ->Tasks-> Android ->signingReports to view the signature information for the various variants of your project. Keytool -v -list -keystore XXXX can also be used.
2. Download the Google-service. json file from the project Settings and replace it with the original project file
Code access
The SDK access
1. Access the Google Login SDK
// The root directory of gradle file allprojects {repositories {Google () // The root directory of gradle file allprojects {repositories {Google () Maven {// url 'https://maven.google.com' //}}} // Implementation 'com. Google. Android. GMS: play - services - auth: 15.0.1'Copy the code
Use Google sign
/ / build GoogleSign Client GoogleSignInOptions gso = new GoogleSignInOptions. Builder (GoogleSignInOptions. DEFAULT_SIGN_IN) .requestIdToken(context.getString(R.string.default_web_client_id)) .requestEmail() .requestProfile() .requestId() .build(); GoogleSignInClient client = GoogleSignIn.getClient(context, gso);Copy the code
/ / lift Google account select the pop-up page Intent signInIntent = mGoogleSignInClient. GetSignInIntent (); activity.startActivityForResult(signInIntent, GOOGLE_SIGN_IN);Copy the code
If your project has its own userCenter in the background, @override public void onActivityResult(int requestCode, int resultCode, Intent data) {if (requestCode! = GOOGLE_SIGN_IN) { return; } Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data); handleSignInResult(task); }Copy the code
Note: all are based on the latest recommended use method and configuration on the official website, see details
Developers.google.com/identity/si…
Facebook login
configuration
Configure your app in Facebook Developer by filling in the package name, Launch class name, and secret key hash.
How to configure the secret key hash in the web page below developers.facebook.com/docs/facebo generation…
Code access
SKD access
// Gradle file: buildscript {repositories} // jCenter ()} // gradle file: implementation 'com. Facebook. Android: facebook - login: [8.1)'Copy the code
Use Facebook signin
See: developers.facebook.com/docs/facebo… There are detailed instructions in it
Q & A
If add the application and the fingerprint is not successful (other items added before), delete the application needs to find the original project and delete to recognize the information support.google.com/firebase/an…
If an error 12500 is returned from calling Google API, you need to configure Support Email in firebase project Settings