Hello,
I have Klaviyo integrated in my react native app with `klaviyo-react-native-sdk`. When I’m sending test notifications from campaign it works well with iOS version. But there is one issue on Android version when app is closed.
Notifications on Android are not displayed when app is closed probably because they don’t include ‘notification’ payload (only ‘data’) so Android won’t show it. I can’t see any option in Klaviyo dashboard to set custom payload for push notifications. Is it somehow manageable?
(I can display notification properly while app is in the background or in the foreground but not when it’s closed)
Thank you
Push notification for React Native Android while app is closed
Best answer by xcapistr
I checked the received notification objects using `react-native-firebase/messaging`.
Here is a comparison of Klaviyo and Firebase notifications:
{
"klaviyo": {
"sentTime": 1738838511431,
"data": {
"title": "Klaviyo test",
"body": "This notification has been sent from Klaviyo",
"notification_tag": "2025-02-06T10:41:51.262325+00:00",
"_k": "{\"Push Platform\": \"android\"}"
},
"messageId": "0:1738838511444799%18965de2f9fd7ecd",
"ttl": 2419200,
"from": "514654180158"
},
"firebase": {
"notification": {
"android": {},
"body": "This notification has been sent from Firebase",
"title": "Firebase test"
},
"sentTime": 1738838603649,
"data": {},
"from": "514654180158",
"messageId": "0:1738838603666709%18965de218965de2",
"ttl": 2419200,
"collapseKey": "com.ascension.app.staging"
}
}
According docs it looks like Klaviyo sends data message and firebase sends notification message. That might be the reason why Klaviyo notifications don’t work when app is closed as only the client app is responsible for processing these messages.
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.