Firebase phone authentication has been used for driver and rider's SMS authenticatioin proccess. It free and has been localized for many countries and languages.
Each apk you generate needs to be signed by a keystore wheter you generate a debug or a release apk. Many API providers encourage you or even make you to have your APK's keystore fingerprint added on their API console so only you and your APK would be able to use that API's resources. With that explanation let's get SHA-1 fingerprint of debug and release keystore and add them on Firebase console because it's mandatory for Firebase Authentication to work too (Optional but recomended for Google Maps too).
If you don't have a release keystore already or don't know how to generate one you can do that in this section. To create a keystore open terminal panel in Android studio and enter following command:
keytool -genkey -v -keystore release.keystore -alias [your_alias_name] -keyalg RSA -keysize 2048 -validity 10000
Don't forget to replace
[your_alias_name]with an alias name of your choice, like
releasekey. after entering this command you will be taken through some questions that you need to fill and will work as signature of your release APKs. after that you will need to enter your release key's passwords and alias in file
gradle.propertiesso generation of SHA-1 key and APK's would be done automatically from now on.
If you have done the previous step correctly this should be pretty easy. Open Gradle panel in Android studio. Then open node of
signingReportwill show a report on
Runpanel that has SHA-1 key for both release key and debug key. Now have this SHA-1 keys copied somewhere because you will need it during applying for Firebase Authentication.
On the firebase project used on the server side installation enabled the "Phone Authentication"
Create 2 Android Apps for driver and rider and assign an application id you will use later for the apps to them.
Use download json button and retrieve the file. Put it in the place on both driver and rider project as firebase instructs you. You will need to only copy this file the rest is already done.
Google Maps has been used for some of application functionalities. you will need to retrieve an API key from Google to have the app working.
You need to have these APIs enabled in library section one by one:
- Maps SDK for Android
- Maps Static API
- Places API
- Distance Matrix API
- Geocoding API
Now go to Credentials section and create a new API key. In next section you will see where you need to paste this key.
You are almost finished and ready to compile your apps. but first let's go to client apps customization file and fill some parameters there. Open android folder in Android Studio 2021.1+
In common project you have this file named
options.xml. open the file which will look like this, In the higlighted line you will require to enter Google Maps API key starting with
AIza. This API key will require to have
Android Maps SDK,
Geocodingenabled from Library.
<string name="email" translatable="false"></string>
<string name="website" translatable="false"></string>
<string name="twitter" translatable="false"></string>
<string name="instagram" translatable="false"></string>
<string name="facebook" translatable="false"></string>
<string name="playStore" translatable="false"></string>
<string name="fabric_key" templateMergeStrategy="preserve" translatable="false"></string>
<string name="google_maps_key" templateMergeStrategy="preserve" translatable="false"></string>
<string name="defaultLocation" translatable="false"></string>
In order to connect driver and rider app to your server open the file named
Config.ktand replace the IP address of server to your server's IP. Keep in mind ports of rider and driver app are different and they should remain same as they are now.
In previous sections you have selected an
applicationId. now change the default
applicationIdto the one you have selected in each project's