Push Data & Taps
Handle push notification taps (cold starts included) and deep-link with the url key in your pushData object.
Every push notification you send through Native Notify can carry a pushData object. When a user taps the notification, that object is delivered to your app — the usual pattern is to put a url (or a screen name) inside it and navigate when the tap arrives.
Sending a pushData object
Include pushData in your API call (or in the send form in your NativeNotify.com dashboard):
{
appId: app-id-number,
appToken: "your-app-token",
title: "Your order shipped",
body: "Tap to track your package",
dateSent: "put your date here as a string",
pushData: { url: "/orders/12345" }
}
Handle taps — cold starts included
Use the useNativeNotifyPress<T>() hook. It returns the pushData of the last tapped notification, and it handles both cases:
- the tap that launched a cold app — the raw expo-notifications response listener does not fire for it, because the response happened before your listener subscribed — and
- taps that arrive while the app is running.
import { useEffect } from 'react';
import { Slot, router } from 'expo-router';
import { useNativeNotifyPress } from 'native-notify';
export default function RootLayout() {
const { data } = useNativeNotifyPress<{ url?: string }>();
useEffect(() => {
if (data?.url) {
router.push(data.url); // Expo Router — or navigation.navigate(...) with React Navigation
}
}, [data]);
return <Slot />;
}
useNativeNotifyPress also returns the full expo-notifications response as notification when you need the title, body, or date:
const { data, notification } = useNativeNotifyPress<{ orderId?: string }>();
getPushDataObject() is a drop-in wrapper that returns just the data — handy if you only need the values. It is a hook too, so call it at the top level of a component.
Deep linking with the url key
Convention: put a url key inside pushData, then hand it to your router when the tap arrives:
- Expo Router:
router.push(data.url)— works with nested segments and typed routes. - React Navigation: pass the url through your linking configuration.
Linking.openURL()needs an absolute URL — send a fullmyapp://…link inpushData, or build one from a path withLinking.createURL()fromexpo-linking.
The prebuilt Notification Inbox rows carry their pushData too, so the same convention works with the inbox's onNotificationPress callback — no notification listener needed.