React Native Case Studies & Practical Application 3 — Questions and Answers
Question 1: A banking app must lock itself immediately when the user leaves and return to the login screen. Which AppState value should trigger this?
- 'inactive'
- 'background' (Correct answer)
- 'extension'
- 'suspended'
Correct answer: 'background'
The 'background' AppState triggers when the app is fully backgrounded, which is the correct moment to enforce security locks.
Question 2: A photo-sharing app uploads images to S3. Large uploads fail on slow connections. What technique improves reliability?
- Increase the fetch timeout to 120 seconds
- Use multipart/chunked upload with retry logic per chunk (Correct answer)
- Compress images client-side before uploading
- Switch from fetch to XMLHttpRequest
Correct answer: Use multipart/chunked upload with retry logic per chunk
Multipart chunked uploads allow retrying only failed chunks rather than restarting the entire upload on connection drops.
Question 3: A ride-sharing app needs to animate a car icon moving smoothly along a route on a map. Which API should drive the animation?
- setState called in a requestAnimationFrame loop
- Animated.timing with useNativeDriver: true on coordinate values (Correct answer)
- LayoutAnimation.configureNext before each coordinate update
- CSS transitions via inline styles
Correct answer: Animated.timing with useNativeDriver: true on coordinate values
Animated.timing with useNativeDriver offloads animation frames to the native thread, ensuring smooth 60fps motion without JS-thread involvement.
Question 4: A healthcare app must support biometric login (Face ID / fingerprint) on both iOS and Android. Which library provides a unified API?
- react-native-keychain
- react-native-biometrics
- expo-local-authentication (Correct answer)
- react-native-touch-id
Correct answer: expo-local-authentication
expo-local-authentication provides a cross-platform API for biometric authentication that works on both iOS and Android without platform-specific code.
Question 5: An event app needs deep linking so that tapping a link in an email opens the correct event detail screen. What must be configured?
- A custom URL scheme in AndroidManifest.xml and Info.plist plus Linking API handling (Correct answer)
- Only a Universal Link in Info.plist
- A push notification payload with a screen parameter
- An App Clip for iOS and Instant App for Android
Correct answer: A custom URL scheme in AndroidManifest.xml and Info.plist plus Linking API handling
Custom URL schemes require manifest entries on both platforms and runtime handling via the Linking API to navigate to the correct screen.
Question 6: A podcast app needs to keep playing audio after the screen is turned off. Which approach is correct for iOS?
- Use BackgroundFetch to restart audio every 15 minutes
- Enable the 'audio' background mode in Xcode capabilities and use AVPlayer (Correct answer)
- Play silence to keep the app active in foreground
- Use PushKit to wake the app for audio
Correct answer: Enable the 'audio' background mode in Xcode capabilities and use AVPlayer
Enabling the 'audio' background mode in Xcode allows AVPlayer-based audio sessions to continue running when the screen is locked.
Question 7: A retail app renders product prices from an API that returns numbers as strings. Prices display as '0' after arithmetic. What is the root cause?
- JavaScript's + operator concatenates strings instead of adding numbers (Correct answer)
- The API response is cached and stale
- React Native rounds floats to integers by default
- The Text component strips decimal points
Correct answer: JavaScript's + operator concatenates strings instead of adding numbers
Using + on string values concatenates them rather than performing numeric addition; parseFloat() or Number() is required first.
A banking app must lock itself immediately when the user leaves and return to the login screen.
Which AppState value should trigger this?