Skip to the page

RN push & background · Concept

Foreground, background and killed-state handling

The interviewer asks

A data message arrives when the app is (a) open, (b) backgrounded, (c) swiped away. What code runs in each case, and where must the background handler be registered?

// index.js
messaging().setBackgroundMessageHandler(async msg => { /* ? */ });
AppRegistry.registerComponent(appName, () => App);

Then

Follow-ups the interviewer asks next

  1. "Why must it be in index.js, outside React?"
  2. "iOS: will a data-only message wake a killed app?"
  3. "Android: why didn't a normal-priority message arrive in Doze?"
  4. "getInitialNotification vs onNotificationOpenedApp?"

The answer

What a strong answer covers

  • Foreground: onMessage (no system UI for data messages, so display it yourself).
  • Background or quit (Android): the background handler runs headless JS, so register it before registerComponent and keep it short.
  • Notification payloads are shown by the OS when the app is in the background.
  • iOS: content-available background pushes are throttled and not delivered after a user force-quit.
  • Android: Doze restricts normal-priority FCM messages, so use high priority sparingly.
  • Tap handling: getInitialNotification (cold start) vs onNotificationOpenedApp (from background).

The red pen

Common traps

Avoid:registering the handler inside a component. Expecting a guaranteed wake on iOS.

Practise this out loud

Say your answer out loud to an AI interviewer that follows up, and get a score for it.

Practise by voice

Practise questions like this out loud

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview