i am working on android app which receive FCM (fire base messaging clouding), when the app is in the background or it is off android system recieve the notification and display it correctly, but the notification is not displayed when the app become in the foreground, i have checked the service which extends FirebaseMessagingService, it is not running and i dont know how to make it run.
the service code:
public class MyService extends FirebaseMessagingService {
public MyService() {
}
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
}
}
the manifest code:
<service android:name=".MyService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
the main activity code:
startService(new Intent(this,MyService.class));