Native capabilitiesIntermediate4h

Platform APIs.

Platform differences and writing iOS/Android-aware code.

What are platform APIs?

iOS and Android differ in conventions, capabilities, and behavior. React Native gives you the Platform module to branch on the current OS, plus platform-specific file extensions, so you can honor each platform's norms from one codebase.

Why it matters

"Write once, run anywhere" is mostly true, but the gaps matter: back buttons, permission dialogs, safe areas, and UI conventions differ. An app that ignores them feels foreign on one platform. Knowing where and how to branch is what makes a cross-platform app feel native on both.

What to learn

  • The Platform module: Platform.OS and select
  • Platform-specific file extensions (.ios.tsx, .android.tsx)
  • Differences in navigation and back behavior
  • Platform UI conventions to respect
  • Checking API and OS version availability
  • Hardware back button on Android
  • Testing on both platforms

Common pitfall

Building and testing only on one platform, then discovering the other is broken near release. The Android hardware back button, different permission flows, and UI norms all behave differently. Run on both platforms throughout development — problems found early are minor; found at submission they are a scramble.

Resources

Primary (free):

Practice

Use Platform.select to apply a small style or behavior difference between iOS and Android, and handle the Android hardware back button on one screen. Run the app on both an iOS simulator and an Android emulator. Done when the app respects each platform's back behavior.

Outcomes

  • Branch on platform with Platform.OS and select.
  • Use platform-specific file extensions.
  • Honor each platform's navigation and UI conventions.
  • Test continuously on both iOS and Android.
Back to Mobile roadmap