Section 07 · 17 rules

Deep links & push notifications

  • DL1 MUST use universal links (iOS) and App Links (Android) on the team’s https domain for links shared with people: web, email, SMS, ads. Keep the custom scheme (myapp://) for links from other apps and auth redirects. Both platforms need a verification file hosted on the domain; follow the installed version’s linking docs (A5).
  • DL2 MUST let the router own link handling. Expo Router maps every route to a URL automatically; React Navigation uses its linking config, which static configuration generates. NEVER parse URLs by hand with Linking listeners in screens.
  • DL3 MUST map external or legacy URLs that match no route in one place: +native-intent.tsx with redirectSystemPath in Expo Router (native only, with no access to auth state or the current route), or the linking config in React Navigation.
  • DL4 MUST treat every link param as untrusted (NV3): validate it with a schema and redirect on failure (NV4). NEVER let a link perform an action by itself (pay, transfer, delete). A link opens a screen; the user confirms the action.
  • DL5 MUST send a signed-out user who opens a protected link through the auth gate (NV5) and then on to the original destination. NEVER drop the destination after sign-in, and NEVER show protected content before it.
  • DL6 MUST handle both a cold start (the link launches the app) and a running app, and test both on a development or release build; Expo Go’s link support is limited.
  • DL7 MUST keep shared URLs working: when a route is renamed, the old path redirects through DL3.
  • DL8 NEVER put tokens, personal data or secrets in link URLs; URLs end up in logs and analytics. One-time tokens (magic links, password reset) expire quickly and are exchanged with the server at once.

Push notifications

  • PN1 MUST use the stack’s notification library: expo-notifications in Expo projects, or the one the repo has (A2). Test on a development build on a real device. iOS push credentials need a paid Apple Developer account; Android needs FCM V1 credentials.
  • PN2 NEVER ask for notification permission at launch. Ask in context, after a screen explains the benefit (“Get notified when your transfer arrives”). If the user declines, the app keeps working and offers a path to Settings later. Android 13+ needs the runtime permission as well.
  • PN3 MUST create Android notification channels by purpose (transactions, security, promotions) at startup, before any notification shows, so users can mute promotions without losing transaction alerts.
  • PN4 MUST register the push token after sign-in, send it to the backend with the user and device, update it when it changes, and unregister it on sign-out. NEVER keep a token registered for a signed-out user.
  • PN5 MUST route a notification tap through the deep-link path: the payload carries a URL for an existing route (data.url), and the app navigates with the router (DL2). Handle the tap that cold-starts the app as well as taps while it runs. NEVER write navigation code per notification type.
  • PN6 MUST validate notification payloads like API responses (AP3). An unknown type or bad data opens a safe default screen, never a crash.
  • PN7 NEVER put sensitive data in notification text (balances, account numbers, personal data); lock screens show it. Say “You received a transfer” and show details after unlock.
  • PN8 MUST set the foreground display handler and the listeners once, at the app root (SE7), each with a cleanup (SE4).
  • PN9 MUST keep notification code in one notifications feature (permission screen, token registration, payload parsing). When a notification means server data changed, invalidate the matching queries (ST7); NEVER copy the payload into state (ST1).
// features/notifications/useNotificationRouting.ts, mounted once in the root layout
export function useNotificationRouting() {
  const last = Notifications.useLastNotificationResponse(); // covers the tap that cold-started the app
  useEffect(() => {
    const url = parseNotificationUrl(last?.notification.request.content.data); // schema-validated, null if bad
    if (url) router.push(url);
  }, [last]);
}