📜  获取设备令牌 firebase - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:48.250000             🧑  作者: Mango

代码示例1
//This is the only one worked for me as of August 29, 2021
FirebaseMessaging.getInstance().getToken().addOnSuccessListener(token -> {
        if (!TextUtils.isEmpty(token)) {
            Log.d(TAG, "token successfully retrieved : " + token);
        } else{
            Log.w(TAG, "token should not be null...");
        }
    }).addOnFailureListener(e -> {
        //handle e
    }).addOnCanceledListener(() -> {
        //handle cancel
    }).addOnCompleteListener(task -> Log.v(TAG, "This is the token : " + task.getResult()));