Android FCM notification issue

前端 未结 4 704
栀梦
栀梦 2021-01-07 06:50

I am struggling with FCM notifications on Android. The issue is only when the app is closed and not running. I am trying to achieve no click activity I don\'t want the app

4条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-07 07:18

    One way is to use data instead of notification to get onMessageReceived() callback both in app foreground or background. The json part is:

    {   
        "data": {
          "title": "notification_title",
          "body": "notification_body"
        },
        "to" : "jh578_gsh....jhHGFJ76FH"
    }
    

    For detail, follow this link: https://stackoverflow.com/a/37845174/5829624

    Edit:

    Method 2:

    Use a click_action payload in your notification payload. In json:

    {   
        "notification": {
          "click_action": "OPEN_ACTIVITY_1",
        },
    }
    

    And add this intent filter in the Activity (which you want to load when you tap on the notification) in your Manifest:

    
      
      
    
    

    Hope this one will solve your problem.

提交回复
热议问题