Handle IOS push notification when in foreground

For IOS, We’re using a custom flash Component to show push notifications received when app is in foreground by adding a custom handler to expo Notification. Is there any way to run this handler only if app is already on foreground when notification was received? I’ve tried checking 'notification.origin' but it has same value 'received' for both cases when app is in foreground and when app is foregrounded by clicking notification

also actual notification message and title is not received, only these keys are present in the Notification object

    actionId: null,
    data: Object,
    origin: "received",
    remote: true,
    userText: null

How to I get notification text and title ?

Hey @vglobal!

Could you provide a snack example of your code? That way I can reproduce and trouble shoot from there


1 Like

I have created a simple snack to demonstrate my issue here …Simple Push notification snack

Notification in system tray has notification title and body but notification object passed to subscribed handler only has whatever is provided in data object no title and body

I’m also missing title/body in foreground push data, expo 32/android.

Hey @vglobal and @moxorama!

If you check out this snack, and use Expo’s Push Notification Tool, it correctly labels notifications as ‘received’ or ‘selected.’

In regards to your other question, I don’t believe that the ‘title’ or ‘body’ fields are accessible from the Notification object, and all data you want to be passed must be done in the ‘data’ field, but I will make sure with the internal team that that’s the case and get back to you (probably after the weekend is over).

1 Like

thanks for your awesome support.
Yes title and body is not in Notification Object, I was just making sure. In our use case we decided to show an alert dropping from top to show same notification body. since notification body is not available in Notification object we had to add body to data as well so that we had notification text available in foreground

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.