对于FCM,当接收通知应用程序崩溃时,错误为无法实例化接收器FirebaseInstanceIdReceiver

时间:2019-04-18 13:51:37

标签: android firebase notifications

对于FCM,当接收通知应用程序时崩溃并出现java.lang.RuntimeException错误:无法实例化接收器com.google.firebase.iid.FirebaseInstanceIdReceiver:java.lang.ClassNotFoundException:未找到类“ com” .google.firebase.iid.FirebaseInstanceIdReceiver“

gradle dependencies: project level 
implementation 'com.google.firebase:firebase-auth:16.2.0'
implementation 'com.google.firebase:firebase-messaging:17.5.0'

gradle dependencies: app level
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.google.gms:google-services:4.2.0'


public class MyFirebaseInstanceIDService extends 
FirebaseInstanceIdService  {
String refreshedToken="";
@Override
public void onTokenRefresh() {
    super.onTokenRefresh();
    refreshedToken = FirebaseInstanceId.getInstance().getToken();
    Log.d("Firebase", "Refreshed token: " + refreshedToken);
}
}




public class MyFirebaseMessagingService extends FirebaseMessagingService 
{

@Override
public void onNewToken(String token) {
    Log.d("messaging", "Refreshed token: " + token);

    // If you want to send messages to this application instance or
    // manage this apps subscriptions on the server side, send the
    // Instance ID token to your app server.
//        sendRegistrationToServer(token);
}
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    super.onMessageReceived(remoteMessage);
    Log.d("notify message",remoteMessage.toString());
}

}

0 个答案:

没有答案