Tutorial for Firebase integration (Push notifications)

I created a tutorial for the firebase integration. You need this for Push notifications.

Tutorial for Firebase integration

1. Account creation

Create yourself an account at Firebase

2. Go to the console

Click on the respective link in the upper right corner of Firebase or go here

3. Create new project

Just choose a name and leave everything on default.

4. Add Application

Click on "“Add Android Application to start” or similar. Put the following as package name:
org.nearbyshops.enduserappnew

Custom package name

If you already changed your package name, put the respective name.
In that case make sure that you changed all the middle names in the code’s file structure. The package right now has a file structure like org/nearbyshops/enduserappnew/CODE
Yours should look like XYZ/PACKAGENAME/enduserappnew/CODE,
where PACKAGENAME.XYZ is supposed to be your domain name but it doesn’t have to be that way necessarily. It can be anything, the domain is recommended though, also in order to avoid confusion.

5. OPTIONAL Add SHA

Look up the following link to create a SHA-1:
SHA

6. Add JSON to code

Download the google-services.json, copy the code and just replace the whole code in your Android project in Nearby-Shops-Android-app/app/google-services.json

7. Skip step 3 of the application configuration

Sumeet already configured all of this

8. Wait for recognization

Clean project, build and start your app.
Then wait for Firebase to recognize your app.

9. Add database

Click on the database tab at the Firebase console, create a new database.
Copy the link and put it into your api_config.properties at database_url

10. Add Admin SDK

Go to your settings in Firebase(icon on the top of sideboard). Go to Service Accounts.
Then click on “Generate new private key”
Copy the key and paste it into firebase_admin_sdk_key.json in your container. (Same directory as the api_config.properties file

11. Test notifications

There are not many notifications included at this moment. But your Shop Owner should get one when an order is placed for his shop.

2 Likes

I get this error :
FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:app:processDebugGoogleServices’.

No matching client found for package name ‘org.nearbyshops.enduserappnew’
my package name is changed btw

Did you put your package Name in step 4 ?

1 Like

it’s fixed , I had to rename some packages manually .
Thanks

1 Like

Updated that part, I hope it is clearer now.