Android
Last updated
Last updated
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:
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.properties
so 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 Tasks->android->signingReport
. Runing signingReport
will show a report on Run
panel 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.
Firebase Auth won't work in Emulator, So always use real device for that purpose.
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.
google-services.json
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.
Go to Google Maps Developers Console and select taxi project which was created in previous section.
Having Billing enabled on your Google Account is mandatory for some API's to work. So make sure you have the Billing enabled or there might be some parts don't work as expected.
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
Maps JavaScript 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.
Server API key can be restricted to IP of server but Dashboard API key requires nginx and domain being set up. For the purpose of installation it is to be remained unrestricted. For production it would be secure to install nginx and restrict the API key accordingly. This is common knowledge and not covered in this documentation.
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
, Places SDK
& Geocoding
enabled from Library.
In order to connect driver and rider app to your server open the file named Config.kt
and 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 applicationId
to the one you have selected in each project's build.gradle
file.