Create a SimpleAndroid App with WebView and Push Notification

If you want to send Push Notification from an Android WebView application, so for this you can use Google Cloud Messaging Product of Firebase.

So for this, first you have to sign in or create your account in Firebase, you can easily create your Google Account for free.

1. After the account is created, you have to click in Get Started-

2. Then you have to go to Add Project-

3. Then enter the name of your project, then click on Continue.

4. Again you have to click on Continue –

5. Then it is possible that you will have the option to select the country, after that you will get the option to select the Firebase account, select it and click in the Create project.

6. Then you have to click on Android’s Icon-

7. Then you have to enter the package name of the app, you can see the package name from Android Studio, then you have to enter a nick name of your app, after that you have to click in the Register App-

8. Then you have to download the file from the option shown below, then click on Next.

9. After that you have to go to Android Studio, then select the project from the dropdown.

10. Then you have to open your package name, after that move the mouse in the app and right click, then go to the Show In explorer.

11. Then you have to go inside the App folder and paste those downloaded from the File Firebase into the App folder –

12. Now you can close the file explorer

13. Then you have to go to Firebase and copy the code shown below, after that you have to go to Android Studio, then double click in build.gradle inside Gradle as shown in the image below-

14. The code that was copied from Firebase has to be pasted in the build.gradle at the location shown in the image-

15. Then you have to double click inside the app by going to build.gradle as shown in the image below-

16. Then you have to paste the code given below as shown in the image (you may have to update the version given in the code, for this watch the video above) –

implementation platform('')
implementation ''
implementation ''

Paste the below given code with fire at the place shown in the image under this code-

apply plugin: ''

Then you have to connect your android studio to Interner and click in Sync Now, and wait a bit till sync is done.

17. Now you have to go to Firebase and click on Next, after that click on Continue in the console-

18. Now you have to create two new java classes, for that we will again go to Android from the project dropdown-

19. Then you have to go to app> java> domain in which your is, by going to that folder you have to right click, then going to New and clicking in java class-

After that you have to create a java class named MyFirebaseMessagingService, then click in Enter-

20. After that paste the given code in the place shown in the image and if there comes an error to import the class, then import the class-

import android.content.Context;
import android.content.Intent;

import androidx.localbroadcastmanager.content.LocalBroadcastManager;


public class MyFirebaseMessagingService extends FirebaseMessagingService {
public void onMessageReceived(RemoteMessage remoteMessage) {
Intent intent = new Intent(this, MainActivity.class);

PendingIntent pendingIntent = PendingIntent.getActivity(this,0,intent,PendingIntent.FLAG_ONE_SHOT);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this);
notificationBuilder.setContentTitle("FCM NOTIFICATION");
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

//Change URL section
String url = remoteMessage.getData().get("url"); //url is the key to be used in firebase for data
LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(this);


21. Now you have to create another Java Class again as before but this time with the name MyFireBaseInstanceIDService –

Then paste the code given below in the MyFireBaseInstanceIDService class to the location shown in the image-

import android.util.Log;


public class MyFireBaseInstanceIDService extends FirebaseInstanceIdService {

private static final String REG_TOKEN = "REG_TOKEN";
public void onTokenRefresh() {
String recent_token = FirebaseInstanceId.getInstance().getToken();


22. After that you have to go to Android Manifest (app> manifests> AndroidManifest.xml) and paste the below given code as shown in the image-

<service android:name=".MyFireBaseInstanceIDService">
<action android:name=""></action>
<service android:name=".MyFirebaseMessagingService">
<action android:name=""></action>

23. Now you have to go to (app> java> domain>> MainActivity) and paste the code below as shown in the image-


Now, before running your application, if you must have been in your application, then uninstall it, then run the app, notification will start in it.

I have told you in the video how to send the notification

Leave a Comment