This Android app demonstrates how you can send notifications from one user to another using Firebase Cloud Messaging (FCM). To send a notification, we need a user token as a recipient, which is stored in the database using the Firebase Realtime Database.
The user authentication is handled with a one-step Google Sign-In powered by Firebase Authentication.
- Each APK will generate one token.
- When the user is authenticated, the token will be stored in the database by user ID.
- Tokens are subject to change under certain conditions. So, we can add a mechanism to store tokens in the database periodically, for example, every time the application is opened.
- Notifications are sent with a recipient token.
- To get the recipient token, we just need to enter the user ID and the app will fetch the token by the user ID from the database.
Check out the release page and download the latest apk.
- Android native with Kotlin
- Android Architecture Components, specifically ViewModel and Material Components
- Firebase Cloud Messaging, send messages and notifications to another device
- Firebase Realtime Database, store and sync data between users in real-time
- Firebase Authentication, secure user authentication systems
- Google Sign-In for Android, support for user authentication using Google account
- Retrofit, REST client framework
- Gson, parsing the JSON format
- Chucker, HTTP inspector
Firstly, clone this repository and import it into Android Studio (git clone https://github.com/ariefzuhri/FCMSpecificNotifications.git
).
- Open the Firebase Console and click
Add project
(or use an existing Firebase sandbox project). - Follow the instructions there to create a new Firebase project.
- Go to
Project Settings
and at the bottom, click on the Android icon to register your Android app. - Follow the instructions there again and make sure the package name matches your app ID in the Android Studio project. It is also required to include a
debug signing certificate SHA-1
to support Google Sign-In in Firebase Authentication. - Download the
google-services.json
file and move it into Android app module root directory (./app
).
- Go to
Authentication
and click theGet started
button to enable it. - Enable
Google
in theSign-in method
section.
- Go to
Realtime Database
and click theCreate database
button to enable it. - Select
Start in test mode
as theSecurity rules
Any contributions, issues, and feature requests are welcome.
Give a ⭐️ if you like this project.
This project is licensed under the MIT License. See the LICENSE
file for details.
This idea is inspired by KOD Dev.