7

I Am making an app which has push notification Property app is working when we hit notification on the foreground , but when app is on background my _backgroundHandler() method is not invoking, its happening only In IOS App Only

Kaushik Chandru
  • 15,510
  • 2
  • 12
  • 30

4 Answers4

6

also struggle this issue.

set payload as below. mutable-content make sense.

apns: {
    payload: {
        aps: {
            'mutable-content': 1, 
            'content-available': 1
        }
    }
}

https://github.com/firebase/flutterfire/issues/9381#issuecomment-1229167020

set "mutable-content:1" in payloads, iOS passes the notification to our notification service app extension.

For more information APNs payload, see the following links:

https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/generating_a_remote_notification

goza
  • 63
  • 1
  • 4
3

Enable background fetch, background processing and remote notification in Xcode preview

Edit

Add mutable key to payload

{ "to": "dWdhfjfjdbzbmjJ5....", "content_available": true, "mutable_content": true,

"data": { "message": "some msg", "mediaUrl": "image url here" },

"notification": { "body": "notification msg", "sound": "default" } }

EDIT


var payload = {
    notification: {
      title: `msg title here`,
      body: `msg body here`
      }`,
    },
    // Set Android priority to "high"
    android: {
      priority: "high",
    },
    // Add APNS (Apple) config
    apns: {
      payload: {
        aps: {
          contentAvailable: true,
        },
      },
      headers: {
        //"apns-push-type": "background", // This line prevents background notification
        "apns-priority": "10",
      },
    },
    token: "dnqTQVso60GfnnuOjHv8_e:APA91bElr-K3xkQMdYHX8VMrasdfasdfkjhasidfgjn"
 };
Kaushik Chandru
  • 15,510
  • 2
  • 12
  • 30
1

Adding this in my payload solved my issue:

apns: {
    payload: {
        aps: {
            'mutable-content': 1, 
            'content-available': 1
        }
    }
}
0

I have face this issue too.

@goza's answer should been accepted.

This is my sending json.

{
   "message":{
      "token":"fcm token",
      "notification":{
         "title":"NotifyTitle",
         "body":"NotifyBody"
      },
      "data":{
         "title":"DataTitle",
         "body":"DataBody"
      },
      "apns":{
          "payload":{
             "aps":{
                "content-available":1
             }
          }
       }
   }
}
youteng li
  • 53
  • 1
  • 12