I am setting up firebase push notification, and as per the documentation I did everything I guess
So what I did is from Tools > Firebase > Cloud Messaging added Dependencies see my gradle
implementation 'com.google.firebase:firebase-core:11.8.0'
implementation 'com.google.firebase:firebase-messaging:11.8.0'
implementation 'com.google.android.gms:play-services-ads:11.8.0'
After this I created a Class MyyFirebaseMessagingService and extended FirebaseMessagingService see below
public class MyFirebaseMessagingService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
Log.d("RefreshedToken", "onMessageReceived: " + remoteMessage.getNotification().getBody());
showNotification(remoteMessage.getNotification().getBody());
}
private void showNotification(String message) {
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), 0);
Notification notification = new Notification.Builder(this)
.setSmallIcon(R.drawable.logo)
.setContentTitle("Quotes App")
.setContentText(message)
.setContentIntent(pendingIntent)
.setAutoCancel(true)
.build();
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
notificationManager.notify(0, notification);
}}
After this I addeed Service in the manifest
<service
android:name=".MyFirebaseMessagingService"
android:enabled="true"
android:exported="true"
>
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
And now when I try to send notification I dont receive it. What am I doing wrong