Push notifications and background work · core
Push notifications: APNs, FCM, tokens and permission
Your server sends a push through FCM (HTTP v1), which delivers to Android directly and to iOS through APNs, so the app must ask for permission at a good moment, register a device token, keep it in sync on refresh and logout, and handle the user saying no.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- Flow: the app gets a device token (FCM token, or the APNs token on iOS) → sends it to your server with userId, deviceId and platform → your server calls FCM HTTP v1 (OAuth2) → FCM delivers to Android, or to APNs for iOS.
- Tokens change (reinstall, restore, clearing data). Listen for token refresh and upsert; delete the token on logout; remove tokens your server reports as invalid.
- Android 13+ needs the POST_NOTIFICATIONS runtime permission. With expo-notifications the prompt only appears after a notification channel exists, so create the channel first.
- Ask in context (after a meaningful action, after a soft pre-prompt). iOS supports provisional (quiet) authorisation. Once denied, you can only send the user to Settings.
- Expo push service: getExpoPushTokenAsync wraps FCM/APNs; getDevicePushTokenAsync returns the raw token if you send through FCM/APNs yourself.
- @react-native-firebase v26+ needs the New Architecture and removed the namespaced API: use the modular functions (getMessaging(), then onMessage(messaging, …)).
- Expo Go cannot receive remote pushes (Android, since SDK 53); use a development build.
The red pen
Common traps: mistake → fix
Mistake: "One token per user"
Fix: a user has many devices; store one row per device.
Mistake: "Ask for every permission at first launch"
Fix: opt-in drops; ask in context.
Mistake: "FCM is Android-only"
Fix: FCM can deliver to iOS through APNs with your APNs key.
Easy to hard
Questions interviewers ask, easy to hard
- Explain end to end how a push reaches an Android phone and an iPhone.
- When does the FCM token change, and how do you keep your server in sync?
- How do you ask for notification permission without killing the opt-in rate?
- What happens after the user taps "Don't allow" on Android 13?
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.