当活动位于前台时,Firebase通知无效

时间:2016-06-24 10:33:14

标签: android firebase firebase-notifications

当我的应用在后台时,我的通知没有问题。有人可以告诉我为什么吗?

这是我的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()+" ");
    }
}

0 个答案:

没有答案