Prerequisite to Create Push Notification for Android App

The following article will give you the understanding to implement Push Notification for your Android App.

1. Push notification implementation in the android app: 
Create a Firebase project 
Before you can add Firebase to your Android app, you need to create a Firebase project to connect to your Android app. Visit Understand Firebase Projects to learn more about Firebase projects.
a. Create a Firebase project:- b. Register your app with Firebase To use Firebase in your Android app, you need to register your app with your Firebase project. Registering your app is often called "adding" your app to your project.
Note: Check out our best practices for adding apps to a Firebase project, including how to handle multiple variants.
1. Go to the Firebase console
2. In the center of the project overview page, click the Android icon (plat_android) or Add app to launch the setup workflow. 
3. Enter your app's package name in the Android package name field. 
What's a package name, and where do you find it? 
Make sure to enter the package name that your app is actually using. The package name value is case-sensitive, and it cannot be changed for this Firebase Android app after it's registered with your Firebase project. 
4. (Optional) Enter other app information: App nickname and Debug signing certificate SHA-1
How are the App nickname and the Debug signing certificate SHA-1 used within Firebase? 
5. Click the Register app
C. Add a Firebase configuration file 
1. Download and then add the Firebase Android configuration file (google-services.json) to your app: a. Click Download google-services.json to obtain your Firebase Android config file. b. Move your config file into the module (app-level) root directory of your app.
What do you need to know about this config file? 
2. To make the values in your google-services.json config file accessible to Firebase SDKs, you need the Google services Gradle plugin (google-services). 
a. In your root-level (project-level) Gradle file (<project>/build.gradle), add the Google services plugin as a buildscript dependency: 
buildscript { 
repositories { 
dependencies { 
// Add the dependency for the Google services Gradle plugin classpath ''
allprojects { 
repositories { 
mavenCentral() } 
In your module (app-level) Gradle file (usually <project>/<app-module>/build.gradle), add the Google services plugin: 
plugins { 
id '' 
// Add the Google services Gradle plugin
id '' 
d. Add Firebase SDKs to your app 
In your module (app-level) Gradle file (usually <project>/<app-module>/build.gradle), add the dependency for the Firebase Cloud Messaging Android library. We recommend using the Firebase Android BoM to control library versioning. 
For an optimal experience with Firebase Cloud Messaging, we recommend enabling Google Analytics in your Firebase project and adding the Firebase SDK for Google Analytics to your app.
dependencies {
implementation '' 
implementation '' 
implementation '' 
e. Add androidmenifest.xml in the code
<action android:name="" /> 
</intent-filter> </service>
android:resource="@drawable/abc_vector_test" /> 
android:name="" android:resource="@color/blue" />
f. Retrieve the current registration token 

This code is implemented in Home Activity
.addOnCompleteListener(new OnCompleteListener<String>() { 
public void onComplete(@NonNull Task<String> task) { 
if (!task.isSuccessful()) { 
Log.w(TAG, "Fetching FCM registration token failed", task.getException()); return; } String token = task.getResult(); // Log and toast String msg = getString(R.string.msg_token_fmt, token); Log.d(TAG, msg); Toast.makeText(MainActivity.this, msg, Toast.LENGTH_SHORT).show(); 
2. Nudge api in app
File name = LoginViewModel
Nudge api after login successfully in the app
Internal fun callNotificationApi(){
This function is call for nudge api in your app

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.