0
0
React Nativemobile~20 mins

Push notifications with FCM in React Native - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
FCM Push Notifications Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
ui_behavior
intermediate
2:00remaining
Handling notification tap behavior
In a React Native app using Firebase Cloud Messaging (FCM), what happens when a user taps a notification while the app is in the background?
AThe app opens but notification data is lost and cannot be retrieved.
BThe app opens and the notification data is available in the onNotificationOpenedApp listener.
CNothing happens; the notification tap is ignored.
DThe app crashes because background notifications are not supported.
Attempts:
2 left
💡 Hint
Think about how notification listeners work when the app is opened from a notification tap.
🧠 Conceptual
intermediate
2:00remaining
FCM token refresh handling
Why is it important to listen for FCM token refresh events in a React Native app?
ABecause the token refresh event deletes all stored notifications.
BBecause the token refresh event triggers the app to restart automatically.
CBecause the FCM token can change and the app needs to update the server with the new token to continue receiving notifications.
DBecause the token refresh event disables push notifications until the app is reinstalled.
Attempts:
2 left
💡 Hint
Think about what happens if the server has an old token.
lifecycle
advanced
2:00remaining
Notification handling in different app states
Consider a React Native app using FCM. Which listener should you use to handle notifications received when the app is in the foreground?
Amessaging().onMessage() listener
Bmessaging().setBackgroundMessageHandler() listener
Cmessaging().getInitialNotification() listener
Dmessaging().onTokenRefresh() listener
Attempts:
2 left
💡 Hint
Foreground means the app is open and visible.
🔧 Debug
advanced
2:00remaining
Debugging missing notifications on Android
A React Native app using FCM on Android does not show notifications when the app is killed (not running). What is a likely cause?
AThe app has no internet permission in AndroidManifest.xml.
BThe app forgot to call messaging().getToken() on startup.
CThe app is using messaging().onMessage() instead of setBackgroundMessageHandler().
DThe notification payload is missing the "notification" key and only contains "data".
Attempts:
2 left
💡 Hint
Android requires a specific payload key to show notifications when the app is not running.
navigation
expert
2:00remaining
Navigating on notification tap with React Navigation
In a React Native app using React Navigation and FCM, how do you ensure the app navigates to a specific screen when a notification is tapped while the app is closed?
AUse messaging().getInitialNotification() to get the notification data and then navigate after the app loads.
BUse messaging().onMessage() to listen for notification taps and navigate immediately.
CUse messaging().setBackgroundMessageHandler() to navigate when the app is closed.
DUse React Navigation's useFocusEffect hook to detect notification taps.
Attempts:
2 left
💡 Hint
Think about how to get notification data when the app starts from a closed state.