Skip to main content
Solved

Push notification for React Native Android while app is closed

  • October 15, 2024
  • 11 replies
  • 871 views

Forum|alt.badge.img+1

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

Best answer by markpiana

@xcapistr have you seen this similar community post? See the bullet specifically about data vs notification messages.

 

11 replies

stephen.trumble
Forum|alt.badge.img+60
  • Klaviyo Alum
  • 1515 replies
  • October 21, 2024

Hey @xcapistr 

Thanks for reaching out for help with this! @Brett_Gatsby or @DavidV would either of you know if this is possible for android?


Forum|alt.badge.img+32
  • Partner
  • 253 replies
  • October 22, 2024

Hello @xcapistr 

 

Trying removing android:exported="false" from this code 

 <service android:name="your.package.name.YourPushService" android:exported="false">            <intent-filter>                <action android:name="com.google.firebase.MESSAGING_EVENT" />            </intent-filter>        </service>

Forum|alt.badge.img+1
  • Author
  • Contributor II
  • 3 replies
  • October 23, 2024

Thanks for helping @Maxbuzz 
I guess the code is from `AndroidManifest.xml` but I don’t have anything like that in it (no `<service>` or `android:exported=false` near messaging service).

App is managed by Expo and in our team we would like to avoid changing native code.

Also notifications sent from the Firebase console or our backend service are displayed correctly whether the app is closed or not. 


Forum|alt.badge.img+1
  • Author
  • Contributor II
  • 3 replies
  • February 6, 2025

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.


Forum|alt.badge.img+1
  • Author
  • Contributor II
  • 3 replies
  • March 12, 2025

So the remaining question is if the problem with notification on android can be related to difference between data and notification message from firebase docs.


markpiana
Klaviyo Employee
Forum|alt.badge.img+7
  • Klaviyo Employee
  • 30 replies
  • Answer
  • March 18, 2025

@xcapistr have you seen this similar community post? See the bullet specifically about data vs notification messages.

 


  • Contributor I
  • 1 reply
  • March 25, 2025

@markpiana 


As stated here →
https://rnfirebase.io/messaging/usage#notifications
 

As stated here →
https://rnfirebase.io/messaging/usage#background--quit-state-messages

Data-only message does not display notification banner at all !!!!


markpiana
Klaviyo Employee
Forum|alt.badge.img+7
  • Klaviyo Employee
  • 30 replies
  • April 15, 2025

@Kaymind Those docs refer to default Firebase functionality. The KlaviyoPushService handles displaying data notifications. Please see this section of our Android SDK docs for more info.


  • Contributor I
  • 1 reply
  • April 20, 2025

After updating to the latest version from spotipremiumapkdescargar.com, I've noticed that I no longer receive push notifications for new songs or updates when the app is closed.
Previously, I used to get alerts for new releases, but now they only appear when the app is open.
Is this a React Native issue or related to the latest app update?
Anyone else facing this?


  • Contributor I
  • 1 reply
  • August 15, 2025

Hi,

Is it this issue has been resolved? if yes, can anyone share the how to?

Thank you


markpiana
Klaviyo Employee
Forum|alt.badge.img+7
  • Klaviyo Employee
  • 30 replies
  • August 25, 2025

Hi all,

As reiterated a few times, Klaviyo intentionally uses data messages as outlined in our SDK docs.

Note: Klaviyo uses data messages to provide consistent notification formatting. As a result, all Klaviyo notifications are handled via onMessageReceived regardless of the app being in the background or foreground. If you are working with multiple remote sources, you can check whether a message originated from Klaviyo with the extension method RemoteMessage.isKlaviyoMessage.”

Make sure that you’re using KlaviyoPushService to handle notifications from Klaviyo. When using KlaviyoPushService , we have not been able to reproduce any issues with notifications not appearing when the app is closed. 

Also if you are using Expo, please see our new Expo plugin, which may simplify development for you.

Thanks,

Mark