获取设备令牌时发送方ID无效 [英] Invalid sender Id while getting device token

查看:59
本文介绍了获取设备令牌时发送方ID无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Android应用程序中进行Firebase云消息传递设置.我不是第一次做,我已经做过很多次了.但是这一次,我在尝试获取设备令牌时遇到一个奇怪的错误无效的发件人ID".我从未在我的项目中使用过任何发件人ID,除了默认存在于google-services.json文件中的项目编号.请帮助我从这个

I am doing Firebase cloud messaging setup in my Android App. I am not doing it first time.I have done it many times. But this time I am getting a strange error "Invalid Sender ID" while trying to get device token.I have never used any Sender Id in My Project ever except Project number which is by default present in google-services.json file.Please help me out of this

.我正在使用此方法生成令牌.我在我的项目中添加了google-services.json文件

.I am using this method to generate token.I have added google-services.json file in my Project

 FirebaseInstanceId.getInstance().getInstanceId()
            .addOnCompleteListener(new OnCompleteListener<InstanceIdResult>() {
                @Override
                public void onComplete(@NonNull Task<InstanceIdResult> task) {
                    if (!task.isSuccessful()) {
                        Toast.makeText(WelcomeActivity.this,task.getException().getMessage(),Toast.LENGTH_LONG).show();
                        Log.w("getInstanceId failed", task.getException());
                        return;
                    }

                    // Get new Instance ID token
                    String token = task.getResult().getToken();
                    Log.v("sssskkkk",token);

                }
            });

我在我的项目中使用以下依赖项

I am using following dependencies in my Project

 implementation 'com.android.support.constraint:constraint-layout:1.0.2'
api fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.firebase:firebase-messaging:17.3.4'
testImplementation('com.android.support.test.espresso:espresso-core:2.2.2')

implementation 'com.squareup.okhttp3:okhttp:3.10.0'
implementation 'me.relex:circleindicator:1.2.2@aar'
implementation 'org.immutables:gson:2.4.0'
implementation 'com.android.volley:volley:1.1.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'

implementation 'com.android.support:multidex:1.0.3'
testImplementation 'junit:junit:4.12'
implementation 'com.borjabravo:readmoretextview:2.0.1'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.github.bumptech.glide:glide:4.8.0'
implementation 'com.github.mabbas007:TagsEditText:1.0.5'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'


implementation 'com.android.support:support-core-utils:28.0.0'

implementation 'com.karumi:dexter:4.2.0'

我很确定在Firebase云消息传递的实现中不会丢失任何内容.此外,当我在具有相同程序包名称的不同项目中使用相同的google-services.json时,一切正常.

I am pretty sure that I am not missing anything in implementation of Firebase cloud messaging.Also when I am using same google-services.json in different project with same package name then all working fine.

推荐答案

是的,我花了大约30个小时后终于解决了.该代码是由以前的开发人员完成的,我发现其中有两个google-services.json文件,一个位于应用程序文件夹中,另一个位于调试文件夹中,因此发件人ID不匹配.因此,我建议所有收到此错误的人:-

Yeah finally I solved it after spending around 30 hours on it.That code was done by previous developer and I found that there were two google-services.json files, one in app folder and another in debug folder so Sender ID's were mismatching in it.So I would like to suggest all those who are getting this error:-

  1. 应检查您是否已将文件复制到正确的app文件夹中.
  2. 应检查文件是否正确,并与FCM中最新下载的google-services.json文件匹配
  3. 应该检查项目中是否存在google-services.json的任何重复文件?

这篇关于获取设备令牌时发送方ID无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆