简体   繁体   English

addCompleteListener()尚未解决-Firebase Cloud Messaging(FCM)

[英]addCompleteListener() is not being resolved - Firebase Cloud Messaging (FCM)

I am wondering why addCompleteListener() is not resolved yet I have provided the necessary dependencies : 我想知道为什么addCompleteListener()尚未解决,但我已经提供了必要的依赖项:

classpath 'com.google.gms:google-services:4.2.0'


implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.google.firebase:firebase-iid:17.0.4'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation 'com.firebase:firebase-jobdispatcher:0.8.5'

I followed this question Stackoverflow same question , but I didn't get any luck. 我跟这个问题跟Stackoverflow一样 ,但是我没有任何运气。

Below is my code,I want to get the device registration token : 下面是我的代码,我想获取设备注册令牌:

FirebaseInstanceId.getInstance().getInstanceId()
                .addCompleteListener(LoginActivity.this,new OnCompleteListener<InstanceIdResult>() {
                    @Override
                    public void onComplete(@NonNull Task<InstanceIdResult> task) {
                        if (!task.isSuccessful()) {
                            return;
                        }
                        String token = task.getResult().getToken();
                        String msg = getString(R.string.fcm_token, token);
                        Log.d("--> FCM Token ", msg);

                    }
                });

Below is the screenshot : 以下是屏幕截图:

在此处输入图片说明

What could lead to this issue ? 是什么导致这个问题?

To solve this, please change the following line of code: 要解决此问题,请更改以下代码行:

FirebaseInstanceId.getInstance().getInstanceId().addCompleteListener(/* ... */);

to

FirebaseInstanceId.getInstance().getInstanceId().addOnCompleteListener(/* ... */);
//                                                  ^^

There is no addCompleteListener method, it's addOnCompleteListener() . 没有addCompleteListener方法,它是addOnCompleteListener()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 MismatchSenderId错误Firebase云消息传递(FCM) - MismatchSenderId error Firebase Cloud Messaging (FCM) Firebase Cloud Messaging(FCM)无法获取数据 - Firebase Cloud Messaging (FCM) not getting data 如何向FCM(Firebase云消息传递)令牌的特定用户发送消息? - How to send a message to a specific user of an FCM (Firebase Cloud Messaging) token? 在Firebase Cloud Messaging上检查新通知。 (FCM) - Check for new notifications on Firebase Cloud Messaging. (FCM) 调用“ https://fcm.googleapis.com/fcm/send”时,Firebase云消息传递出现内部服务器错误 - Firebase cloud messaging getting internal server error when calling “https://fcm.googleapis.com/fcm/send” 我无法在我的 android 仿真器中接收 Firebase 云消息传递 FCM - I Can' t receive the Firebase Cloud Messaging FCM In my android emulator 是否可以在没有 Firebase Cloud Messaging (FCM) 的情况下向所有安装了我的应用程序的设备发送推送通知? - is it possible to make push notifications to all devices which had installed my application without Firebase Cloud Messaging (FCM)? FCM Cloud Messaging 与 Notifications 和 Message 的区别 - FCM Cloud Messaging difference from Notifications and Message Firebase 云消息传递 - onMessageReceived 不起作用 - Firebase Cloud Messaging - onMessageReceived not working 使用Firebase云消息传递的通知 - Notification using Firebase cloud Messaging
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM