Cannot find "data" parameter in pushnotification payload

while sending a message, I’m passing a id using the “Data” parms.
However its there in the normal message.
But i cant find the “Data” parameter in the push notification payload.

As per the doc, The “data” is there in notification payload.

any help on this?

Hey @Manoj_Kanth,

Can you show me(code) how you are trying to get the “data” in the notification payload?

Hey @Alex_Preston thank for your quick reply.
Please find it below. Got struct a week depending on this. Can you please help me on this.

class NotificationService: UNNotificationServiceExtension {

var contentHandler: ((UNNotificationContent) -> Void)?
var bestAttemptContent: UNMutableNotificationContent?

override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
    
    self.contentHandler = contentHandler
    bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
    
    guard let payload = bestAttemptContent?.userInfo else {
        return contentHandler(bestAttemptContent ?? UNMutableNotificationContent())
    }
    guard let sendbird = payload["sendbird"] as? [String: Any] else {
        return contentHandler(bestAttemptContent ?? UNMutableNotificationContent())
    }
    
    guard let channel = (sendbird["channel"] as? Dictionary<String, Any>) else {
        return contentHandler(bestAttemptContent ?? UNMutableNotificationContent())
    }
    
    guard let sender = (sendbird["sender"] as? Dictionary<String, Any>) else {
        return contentHandler(bestAttemptContent ?? UNMutableNotificationContent())
    }
    
    guard let recipient = (sendbird["recipient"] as? Dictionary<String, Any>) else {
        return contentHandler(bestAttemptContent ?? UNMutableNotificationContent())
    }
    
    let channelURL = channel["channel_url"] as! String
    let channelName = channel["name"] as! String
    let channelType = channel["custom_type"] as! String
    let senderId = sender["id"] as! String
    let recipientId = recipient["id"] as! String
    let messageId = sendbird["message_id"] as! Int64
    let createdAt = sendbird["created_at"] as! Int64
    let data = sendbird["data"] as! String

}

Hey @Manoj_Kanth,

Were you able to get any other parameter? Also are you able to set a breakpoint to see the whole json object to verify that there is data?

Hey @Alex_Preston,
yes. i tried with breakpoints and saw the all data. totally im getting 17 items in sendbird object. Data is not there.

Hey @Manoj_Kanth,

Can you DM me you appID. There is an attribute on applications which if enabled can disable data on the payload.

Hey @Alex_Preston
Sorry i couldn’t see any option to send DM to you.
Can you please guide me on this…

hey @Alex_Preston. Could you please guide me on this as well. Here is the full notifications payload, and I don’t have message data here as well.
▿ 0 : 2 elements
▿ key : AnyHashable(“aps”)
- value : “aps”
▿ value : 4 elements
▿ 0 : 2 elements
- key : badge
- value : 6
▿ 1 : 2 elements
- key : alert
- value : You have an upcoming event test
▿ 2 : 2 elements
- key : category
- value : sendbird_admm
▿ 3 : 2 elements
- key : sound
- value : default
▿ 1 : 2 elements
▿ key : AnyHashable(“sendbird”)
- value : “sendbird”
▿ value : 16 elements
▿ 0 : 2 elements
- key : app_id
- value : XXXXXXXXXXXXXXX
▿ 1 : 2 elements
- key : custom_type
- value : notification
▿ 2 : 2 elements
- key : category
- value : messaging:offline_notification
▿ 3 : 2 elements
- key : channel_type
- value : messaging
▿ 4 : 2 elements
- key : unread_message_count
- value : 6
▿ 5 : 2 elements
- key : message
- value : You have an upcoming event test
▿ 6 : 2 elements
- key : created_at
- value : 1615490400218
▿ 7 : 2 elements
- key : push_sound
- value : default
▿ 8 : 2 elements
- key : channel
▿ value : 3 elements
▿ 0 : 2 elements
- key : channel_url
- value : XXXXXXXXXXXXXXXXXXXXXX
▿ 1 : 2 elements
- key : name
- value : XXXXXXXXXXXXXXXXXXXXXX
▿ 2 : 2 elements
- key : custom_type
- value : NOTIFICATIONS
▿ 9 : 2 elements
- key : type
- value : ADMM
▿ 10 : 2 elements
- key : files
- value : 0 elements
▿ 11 : 2 elements
- key : translations
- value : 0 elements
▿ 12 : 2 elements
- key : recipient
▿ value : 3 elements
▿ 0 : 2 elements
- key : push_template
- value : default
▿ 1 : 2 elements
- key : id
- value : 6048ccf3793a1b1a8bdb75e8
▿ 2 : 2 elements
- key : name
- value : Illia Postoienko
▿ 13 : 2 elements
- key : audience_type
- value : only
▿ 14 : 2 elements
- key : mentioned_users
- value : 0 elements { … }
▿ 15 : 2 elements
- key : message_id
- value : 863817013

Hello. We have the same problem. I’m sending a text message to a chat using the Platform API. In the message payload, I specify the “data” parameter as detailed here:

In the message that comes to the chat, I can see my passed data (Android)

However, in the corresponding push notification the “data” key is absent

Please advise how I can include custom data into the push notification. Thanks!

Because the data field can store a large amount of information, it is not included by default. In order for it to be included in the payload, an attribute needs to be changed by the Sendbird team on a per application basis. Please note that including data can cause truncation due to limits of APNS and FCM.

If you’re interested in having that done, I’d recommend reaching out to our Support team via the Dashboard.

2 Likes