You need to create a class as MyFirebaseMessagingService
and extends FirebaseMessagingService
public class MyFirebaseMessagingService extends FirebaseMessagingService {
//Called when a message is received.
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {//code goes here}
//Called when a new token for the default Firebase project is generated.
@Override
public void onNewToken(String token) {//code goes here}
}
NOTE: There can only be one service in each app that receives FCM messages. If multiple are declared in the Manifest then the first one will be chosen.
You can read more on FirebaseMessagingService
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…