4

I currently using FCM to push notification to my flutter app.

I try to launch the app when the user tap on a notification when the app is in background

I got this terminal log when I try to tap on a notification

    E/FirebaseMessaging(24830): Notification pending intent canceled

I also put this in my AndroidManifest.xml as the official document

    <intent-filter>
        <action android:name="FLUTTER_NOTIFICATION_CLICK" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>

This is my payload of the push notification

    { notification: 
       { 
         title: 'title',
         body: 'body',
         badge: '1',
         icon: 'https://miro.medium.com/max/11400/1*lS9ZqdEGZrRiTcL1JUgt9w.jpeg',
         click_action: 'FlUTTER_NOTIFICATION_CLICK',
         sound: 'default' 
       },
      data: { type: '4' } 
    }  

What did I miss?

Józef Podlecki
  • 10,453
  • 5
  • 24
  • 50
Purinut
  • 213
  • 4
  • 9

1 Answers1

2

first of all your payload should be encoded as JSON :

     {
       'notification': {
         'body': 'this is a body',
         'title': 'this is a title'
       },
       'priority': 'high',
       'data': {
         'click_action': 'FLUTTER_NOTIFICATION_CLICK',
         'id': '1',
         'status': 'done'
       },
       'to': await firebaseMessaging.getToken(),
     }

after this try remove 'click_action': 'FLUTTER_NOTIFICATION_CLICK', from your payload and check its work or not

Amir
  • 2,225
  • 2
  • 18
  • 27