当我的应用程序在后台时,我的通知没有问题。有人能告诉我为什么吗?
这是我的 manifest.xml:
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".CrowdWeather"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme" >
<activity android:name=".MainActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:name=".FirebaseNotification">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
</application>
这是 FirebaseNotification.java:
public class FirebaseNotification extends FirebaseMessagingService {
public static final String TAG= "Firebase rocks";
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Log.d("getFrom",remoteMessage.getFrom()+" ");
Log.d("messageData",remoteMessage.getMessageType()+" ");
Log.d("notificationBody",remoteMessage.getNotification().getBody() +" ");
Log.d("total",remoteMessage.getTtl()+" ");
}
}