Chapter 6. Platform APIs
React Native does not wrap all of its host platform’s functionality by default; some platform APIs will require you to either write your own modules, or use modules written by others in the React Native community. We will cover that process in Chapter 7. The docs are the best place to check if an API is supported.
This chapter covers some of the available platform APIs. For our example, we’ll make some modifications to the Weather application from earlier. We’ll add geolocation to the app, so that it detects the user’s location automatically. We will also add “memory” to the app, so it will remember your previously searched locations. Finally, we’ll use the camera roll to change the background image to one of the user’s photos.
While relevant code snippets will be presented in each section, the full code for the application is included in “The SmarterWeather Application”.
iOS and Android Compatibility
Cross-platform support for these APIs is a work in progress, so while
AsyncStorage is supported on both iOS and Android, geolocation and the camera roll are currently iOS-only. ...