FCM onMessageReceived not calling Android

后端 未结 2 494
遥遥无期
遥遥无期 2020-12-18 11:55

I am facing one problem while implementing FCM in Android application.

Everything works fine, my service onMessageReceived() is not calling. But I am ge

2条回答
  •  旧时难觅i
    2020-12-18 11:57

    First, follow instructions from this guide, they are very clear and easy, or you can clone sample code from here and see for yourself what is wrong.

    Secondly have you read these comments regarding onMessageReceived()

    // [START_EXCLUDE]
    // There are two types of messages data messages and notification messages. Data messages are handled
    // here in onMessageReceived whether the app is in the foreground or background. Data messages are the type
    // traditionally used with GCM. Notification messages are only received here in onMessageReceived when the app
    // is in the foreground. When the app is in the background an automatically generated notification is displayed.
    // When the user taps on the notification they are returned to the app. Messages containing both notification
    // and data payloads are treated as notification messages. The Firebase console always sends notification
    // messages. For more see: https://firebase.google.com/docs/cloud-messaging/concept-options
    // [END_EXCLUDE]
    

    Look for following comment in this class

    // Also if you intend on generating your own notifications as a result of a received FCM
    // message, here is where that should be initiated. See sendNotification method below.
    

    For more see: https://firebase.google.com/docs/cloud-messaging/concept-options

提交回复
热议问题