Я работаю с push-уведомлениями с помощью firebase. Я могу получать уведомления
когда мое приложение закрыто или находится в фоновом режиме, но я не получаю уведомления
когда мое приложение работает, помогите мне, чтобы я мог получать уведомления, даже когда мое приложение работает
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
shownotifeaction(remoteMessage.getNotification().getBody());
}
public void shownotifeaction(String message) {
PendingIntent pi = PendingIntent.getActivity(this, 0, new Intent(this, Splash_Img.class), 0);
Notification notification = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_stat_name)
.setContentTitle("Porwal")
.setContentText(message)
.setContentIntent(pi)
.setAutoCancel(true)
.build();
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(0, notification);
}
}
<service
android:name=".MyFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/ic_stat_name" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/colorAccent" />