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.
Turn on notifications for Android devicesTap More on the bottom navigation bar and select Settings. Tap Turn on notifications. Tap Notifications. Tap Show notifications.
The FCM backend receives the message request, generates a message ID and other metadata, and sends it to the platform specific transport layer. When the device is online, the message is sent via the platform-specific transport layer to the device. On the device, the client app receives the message or notification.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With