Lấy token của Firebase Cloud Messaging bị null

Chào mn! cho mình hỏi là mình đang dùng demo của fcm để push notification. Nhưng khi test thì lúc lấy token nó lại bị null? cho mình hỏi là mình cần lưu ý bước nào hông? https://github.com/firebase/quickstart-android/tree/master/messaging

bạn xem lại lúc gửi mess thì chọn đúng app chưa, xem lại file google-services.json đã đúng thông tin với lúc đăng ký project trên firebase chưa :smiley:
mình đoán thế, vì cũng k rõ bạn làm như nào :v:

thanks bạn nhé, mình chạy trên máy thật thì được, mà trên máy ảo thì không get được token…bạn biết trường hợp này thường do gì hông?

cho mình xem nội dung phần đăng ký Service trong file AndroidManifest của bạn

AndroidManifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.androidtutorialpoint.firebasecloudmessagingtutorial">
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.VIBRATE"/>

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        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>
        <activity android:name=".ResultActivity"/>
        <service
            android:name=".MyAndroidFirebaseMsgService">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT"/>
            </intent-filter>
        </service>
        <service
            android:name=".MyAndroidFirebaseInstanceIdService">
            <intent-filter>
                <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
            </intent-filter>
        </service>
    </application>

</manifest>

máy ảo có google play sevice chưa

có rồi nhé bạn, mình chạy trên thiết bị thật thì lại được. Và cho mình hỏi bạn có cách nào bắt được sự kiện nhận notication khi app đang chạy hông vậy?

83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?