如何在 android 活动中获取 Firebase 令牌?

德鲁桑

我正在使用setToken(FirebaseInstanceId.getInstance().getToken())代码来获取令牌,但出现以下错误

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/util/zzv;

构建.gradle

dependencies {
    implementation 'de.hdodenhof:circleimageview:2.2.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.squareup.retrofit2:retrofit:2.4.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
    implementation 'com.squareup.okhttp3:okhttp:3.10.0'
    implementation 'android.arch.lifecycle:extensions:1.1.0'
    implementation 'com.google.firebase:firebase-auth:16.0.5'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    annotationProcessor "android.arch.lifecycle:compiler:1.1.0"
    //noinspection GradleCompatible
    implementation 'com.android.support:recyclerview-v7:28.0.0-rc02'
    implementation 'pub.devrel:easypermissions:0.4.0'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0-rc02'
    implementation 'com.google.firebase:firebase-messaging:11.8.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    implementation 'net.bohush.geometricprogressview:geometricprogressview:1.1.1'
    implementation project(path: ':andoird-sdk')
    implementation project(path: ':opentok-android-sdk-2.16.3')

    implementation 'com.android.support:multidex:1.0.3'
}

apply plugin: 'com.google.gms.google-services'

上面的代码是我的build.gradle。帮我解决问题。

索纳利羽衣甘蓝

您需要使用 FirebaseMessagingService 来获取令牌 .. 您将获得令牌到它自己的方法中

public class MyFirebaseMessagingService extends FirebaseMessagingService {

@Override
    public void onNewToken(final String token) {

/// you will get token here you 
    enter code here

}

}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何在Firebase Android中获取所有活动的实时侦听器

如何在Android中安全存储访问令牌和机密?

如何在访问令牌过期时自动获取刷新令牌并使用android中的HttpURLConnection获取401?

如何从Firebase获取所有设备令牌?

Android + Firebase Auth + REST API:如何正确使用令牌?

如何在Java中获取令牌

如何在Android中从Cloud Firestore Firebase获取或获取数据

使用Firebase在Android中推送通知获取令牌

如何从firebase_auth获取令牌

如何在Android中生成Firebase注册令牌

如何在令牌中存储令牌?

如何在android中获取webview的当前活动

如何在Android的社交认证中获取访问令牌以及如何重用它们

如何在Android的地图活动中从URL获取JSON数据

如何在Android中获取访问令牌贝宝

如何在特定事件中获取Firebase令牌

如何在Android的非活动类中获取ActionBar的标题

为什么不获取 Android Firebase FCM 注册令牌?

如何从firebase注销令牌?

如何获取 Firebase 令牌?

如何在 Firebase for Android 中获取根节点的子节点

如何在 Angular 2 中从 Firebase 获取有效的访问令牌

如何在jsonarray firebase android中获取对象?

如何在android中从Firebase获取子节点的子节点?

如何获得firebase令牌?

如何获得firebase令牌?

如何在 Xamarin.Forms Android 中保存 Firebase 设备令牌

如何获取 Firebase ID 令牌?

你如何在android studio中存储访问令牌和刷新令牌?