I tried to test my app with sending the notification via console in firebase cloud messaging, But when my app in the foreground or still running. The notification do not show in the device and the log in the firebase messaging service is triggered.
But when i destroy my app, the notification work nicely.
This is my manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.yehezkiel.eclassapp">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="@mipmap/eclass_logo1"
android:label="@string/app_name"
android:roundIcon="@mipmap/eclass_logo1"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:replace="android:icon">
<service
android:name=".myFirebaseInstanceTokenID">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<activity
android:name=".LoginActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity" />
<activity android:name=".Tugas" />
<activity
android:name=".DetailActivity"
android:label="@string/title_activity_detail"
android:theme="@style/AppTheme" />
<activity android:name=".NilaiActivity" />
<activity android:name=".BaseActivity" />
<activity android:name=".MateriActivity" />
<activity android:name=".NilaiDetailActivity" />
<activity android:name=".PesertaActivity"></activity>
</application>
</manifest>
This my firebasemessagingservice
public class myFirebaseInstanceTokenID extends FirebaseMessagingService {
private static final String TAG = "FirebaseMessagingServce";
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
if (remoteMessage.getData().size() > 0) {
Log.e(TAG, "Message data payload: " + remoteMessage.getData());
}
Log.e(TAG, "Tidak ada Data");
}
}