永远不会调用onMessageReceived

时间:2019-05-22 13:15:52

标签: android firebase firebase-cloud-messaging

我升级了Firebase依赖项。但是我不再收到推送通知,因为onMessageReceived永远不会在前台或后台调用

我的gradle对firebase的依赖性:

implementation "com.google.firebase:firebase-core:16.0.9"
implementation "com.google.firebase:firebase-messaging:18.0.0"
implementation "com.google.firebase:firebase-iid:18.0.0"

我的清单:

<service android:name=".TestService">
     <intent-filter>
         <action android:name="com.google.firebase.MESSAGING_EVENT" />
     </intent-filter>
</service>

我的服务:

public class TestService extends FirebaseMessagingService {
private static final String TAG = makeLogTag(TestService.class);

@Override
public void onNewToken(String refreshedToken) {
    super.onNewToken(refreshedToken);
    LOGE(TAG, "Refreshed token: " + refreshedToken);
}

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    super.onMessageReceived(remoteMessage);
    Map<String, String> data = remoteMessage.getData();

    LOGE(TAG, "Received FCM message from : " + remoteMessage.getFrom() + " 
     data : " + data);
     }
 }

0 个答案:

没有答案