<i id='cdGoY'><tr id='cdGoY'><dt id='cdGoY'><q id='cdGoY'><span id='cdGoY'><b id='cdGoY'><form id='cdGoY'><ins id='cdGoY'></ins><ul id='cdGoY'></ul><sub id='cdGoY'></sub></form><legend id='cdGoY'></legend><bdo id='cdGoY'><pre id='cdGoY'><center id='cdGoY'></center></pre></bdo></b><th id='cdGoY'></th></span></q></dt></tr></i><div id='cdGoY'><tfoot id='cdGoY'></tfoot><dl id='cdGoY'><fieldset id='cdGoY'></fieldset></dl></div>

    <small id='cdGoY'></small><noframes id='cdGoY'>

  • <legend id='cdGoY'><style id='cdGoY'><dir id='cdGoY'><q id='cdGoY'></q></dir></style></legend>

        <tfoot id='cdGoY'></tfoot>
          <bdo id='cdGoY'></bdo><ul id='cdGoY'></ul>

        Firebase 云消息传递令牌未生成

        时间:2023-07-28

        <small id='3FCCg'></small><noframes id='3FCCg'>

        <legend id='3FCCg'><style id='3FCCg'><dir id='3FCCg'><q id='3FCCg'></q></dir></style></legend>
        • <i id='3FCCg'><tr id='3FCCg'><dt id='3FCCg'><q id='3FCCg'><span id='3FCCg'><b id='3FCCg'><form id='3FCCg'><ins id='3FCCg'></ins><ul id='3FCCg'></ul><sub id='3FCCg'></sub></form><legend id='3FCCg'></legend><bdo id='3FCCg'><pre id='3FCCg'><center id='3FCCg'></center></pre></bdo></b><th id='3FCCg'></th></span></q></dt></tr></i><div id='3FCCg'><tfoot id='3FCCg'></tfoot><dl id='3FCCg'><fieldset id='3FCCg'></fieldset></dl></div>

              <tbody id='3FCCg'></tbody>
            <tfoot id='3FCCg'></tfoot>
              • <bdo id='3FCCg'></bdo><ul id='3FCCg'></ul>

                1. 本文介绍了Firebase 云消息传递令牌未生成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  AndroidStudio 中的 FCM 设置 - 工具 - Cloud Messaging 中的 Firebase 助手设置成功.因此,设置已更正,但未生成令牌.通过 MainActivity 中的令牌显示在 logcat 和 Config 类中未生成令牌,但其显示为空.运行问题继续后卸载的应用程序.我也尝试了不同的模拟器,但没有任何解决方案.

                  FCM setup in AndroidStudio- tools- Firebase Assistant in Cloud Messaging setup to Successfully. So, setup is Corrected but Token is not generated.token is not generated in logcat and Config Class through token display in MainActivity but its display null. Uninstalled app after the run issue continues. I also try different emulator but not any solution.

                  MyFirebaseInstanceIDService.java

                  MyFirebaseInstanceIDService.java

                  public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService {
                  
                      private static final String TAG = "MyFirebaseIIDService";
                      @Override
                      public void onTokenRefresh() {
                  
                          String newToken = FirebaseInstanceId.getInstance().getToken();
                          Log.d(TAG, "Refreshed token: " + newToken);
                          Config.TOKEN = newToken;
                      }
                  }
                  

                  AndroidManifest.xml

                  AndroidManifest.xml

                  <uses-permission android:name="android.permission.INTERNET" />
                  
                  <application
                      android:allowBackup="true"
                      android:icon="@mipmap/ic_launcher"
                      android:label="@string/app_name"
                      android:roundIcon="@mipmap/ic_launcher_round"
                      android:supportsRtl="true"
                      android:theme="@style/AppTheme">
                      <activity android:name=".MainActivity">
                          <intent-filter>
                              <action android:name="android.intent.action.MAIN" />
                  
                              <category android:name="android.intent.category.LAUNCHER" />
                          </intent-filter>
                      </activity>
                  
                      <service
                          android:name=".MyFirebaseInstanceIDService">
                          <intent-filter>
                              <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
                          </intent-filter>
                      </service>
                  
                  </application>
                  

                  build.gradle(项目级)

                  build.gradle(Project-level)

                    dependencies {
                          classpath 'com.android.tools.build:gradle:2.3.0'
                  
                          // NOTE: Do not place your application dependencies here; they belong
                          // in the individual module build.gradle files
                          classpath 'com.google.gms:google-services:3.0.0'
                      }
                  

                  build.gradle(应用级)

                  build.gradle(app-level)

                  dependencies {
                  
                      compile fileTree(include: ['*.jar'], dir: 'libs')
                      androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
                          exclude group: 'com.android.support', module: 'support-annotations'
                      })
                      compile 'com.android.support:appcompat-v7:26.+'
                      compile 'com.android.support.constraint:constraint-layout:1.0.2'
                      compile 'com.google.firebase:firebase-messaging:10.0.1'
                      testCompile 'junit:junit:4.12'
                      compile 'com.squareup.okhttp:okhttp:2.0.0'
                  }
                  
                  apply plugin: 'com.google.gms.google-services'
                  

                  推荐答案

                  如果需要,您可以在应用中的任何位置使用此代码获取 Firebase 实例 ID 令牌:

                  At any point in your app, you can use this code to get the Firebase instance ID token if you need it:

                  String token = FirebaseInstanceId.getInstance().getToken();
                  

                  您的 FirebaseInstanceIdService 只会在令牌更改时执行.Firebase 文档 指出:

                  Your FirebaseInstanceIdService will only get executed when the token changes. The Firebase documentation states:

                  实例 ID 是稳定的,除非:

                  Instance ID is stable except when:

                  • 应用删除实例 ID
                  • 应用已在新设备上恢复
                  • 用户卸载/重新安装应用
                  • 用户清除应用数据

                  如果这些事情都没有发生在您的应用上,那么您的 FirebaseInstanceIdService 只会在您的应用安装在设备上时第一次运行时执行.

                  If none of those things happen to your app, then your FirebaseInstanceIdService will only ever get executed the first time that your app runs when it is installed on a device.

                  这篇关于Firebase 云消息传递令牌未生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:离子 2 在后台的 FCM 无法正常工作 下一篇:如何使用 Firebase 将多个通知合并为一个?

                  相关文章

                  • <bdo id='P2neG'></bdo><ul id='P2neG'></ul>

                      <legend id='P2neG'><style id='P2neG'><dir id='P2neG'><q id='P2neG'></q></dir></style></legend>

                      <i id='P2neG'><tr id='P2neG'><dt id='P2neG'><q id='P2neG'><span id='P2neG'><b id='P2neG'><form id='P2neG'><ins id='P2neG'></ins><ul id='P2neG'></ul><sub id='P2neG'></sub></form><legend id='P2neG'></legend><bdo id='P2neG'><pre id='P2neG'><center id='P2neG'></center></pre></bdo></b><th id='P2neG'></th></span></q></dt></tr></i><div id='P2neG'><tfoot id='P2neG'></tfoot><dl id='P2neG'><fieldset id='P2neG'></fieldset></dl></div>
                    1. <tfoot id='P2neG'></tfoot>

                    2. <small id='P2neG'></small><noframes id='P2neG'>