简体   繁体   中英

Why Android is not receiving FCM push notification?

I am working on an Android project and trying to receive Push Notifications using FCM. I implemented everything just like it is described here , on official documentation of FCM.

I tested my work by sending demo notification from Firebase console and it worked. I used web key in my Django website and it sends notification to FCM servers and my Android app receives is properly. But there is a problem with that. App only receives notification when it is connected to Android Studio and debug app is installed and running. If I exit from debug app and try, it doesn't receive it. I changed priority to hight , added content_available = true but still not working properly.

I checked the error log in Android Studio and found this,

W/GCM-DMM: broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10000000 pkg=com.app.android (has extras) }

I think GCM is playing part in the scene, and I don't know what to do to solve this error because I am not working with GCM code at all as everything is migrated to FCM. Can anyone tell me what else I need to do to start receiving push notification when my device is not connected with Android Studio and debug app is not running?

NOTE: My django code works fine and I see success message in response from FCM server.

Thanks.

add this to service manifest :

android:enabled="true"
android:exported="true">

just like this :

     <service
        android:name=".firebase.MyFirebaseMessagingService"
        android:enabled="true"
        android:exported="true">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
    </service>
    <service
        android:name=".firebase.MyFirebaseInstanceIDService"
        android:enabled="true"
        android:exported="true">
        <intent-filter>
            <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
        </intent-filter>
    </service>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM