0
0
React Nativemobile~20 mins

Push notifications (expo-notifications) in React Native - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Push Notifications Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
ui_behavior
intermediate
1:30remaining
What happens when a notification is received while the app is in the foreground?
Using expo-notifications, what is the default behavior when a push notification arrives while the app is open and active on the screen?
AThe notification is received silently without any alert or sound.
BThe notification is shown as a system alert banner automatically.
CThe app crashes due to unhandled notification event.
DThe notification triggers a vibration but no visual alert.
Attempts:
2 left
💡 Hint
Think about how notifications behave when the user is already using the app.
🧠 Conceptual
intermediate
1:00remaining
Which permission is required to receive push notifications on iOS?
To receive push notifications on an iOS device using expo-notifications, which permission must the app request from the user?
ALOCATION
BNOTIFICATIONS
CCAMERA
DCONTACTS
Attempts:
2 left
💡 Hint
Think about what permission controls alerts and badges on iOS.
lifecycle
advanced
2:00remaining
When is the push token generated and how to handle it?
In expo-notifications, when is the push notification token generated and what is the best practice to handle it in your React Native app?
AThe token is generated on app launch after permissions are granted; handle it by requesting permissions and then calling getExpoPushTokenAsync.
BThe token is generated only on Android devices; iOS does not use tokens.
CThe token is generated automatically without any permission; no need to handle it explicitly.
DThe token is generated only after the user taps a notification; handle it in notification response listener.
Attempts:
2 left
💡 Hint
Consider when the app can communicate with the notification service and what steps are needed.
🔧 Debug
advanced
2:00remaining
Why does this notification handler not trigger on Android?
Consider this code snippet in a React Native app using expo-notifications: import * as Notifications from 'expo-notifications'; Notifications.setNotificationHandler({ handleNotification: async () => ({ shouldShowAlert: true, shouldPlaySound: false, shouldSetBadge: false, }), }); useEffect(() => { const subscription = Notifications.addNotificationReceivedListener(notification => { console.log('Notification received:', notification); }); return () => subscription.remove(); }, []); Why might the console.log never appear on Android when a notification arrives while the app is foregrounded?
AThe listener is removed immediately after being added, so it never receives notifications.
BAndroid requires a different notification handler setup; this code only works on iOS.
CThe notification is not received because the app lacks notification permissions on Android.
DThe notification is handled by the system and not delivered to the listener because the notification handler returns shouldShowAlert: true.
Attempts:
2 left
💡 Hint
Think about how the notification handler affects delivery to listeners.
navigation
expert
2:30remaining
How to navigate to a specific screen when a notification is tapped?
In a React Native app using expo-notifications and React Navigation, how can you navigate to a specific screen when the user taps a push notification that opens the app?
AUse Notifications.addNotificationReceivedListener to detect taps and call navigation.navigate inside it.
BUse React Navigation's useFocusEffect to check if the app was opened by a notification and navigate accordingly.
CUse Notifications.addNotificationResponseReceivedListener to detect notification taps and then call navigation.navigate with the target screen.
DSet a deep link URL in the notification payload and configure React Navigation to handle it automatically without listeners.
Attempts:
2 left
💡 Hint
Consider which listener specifically handles user interaction with notifications.