Jill
Jill

Reputation: 533

React Native - Differences between Android and IOS

Is the code for building an app for ios and android the same or are they different? I know there are two separate files one with .ios and one with .android but that's about where my knowledge ends. This is for react native. Thanks!

Upvotes: 3

Views: 3656

Answers (2)

Robel Robel Lingstuyl
Robel Robel Lingstuyl

Reputation: 1591

Background processing is a huge thing that I didn't realize initially since I built on iOS to start. I use Redux-Observable and connect to a BLE device that sends me messages regularly. If my app is in the background iOS continues to work and get the messages and fire additional epics. On Android this is not the case when the app is in the background. I get my message from the native ble module then nothing happens until the app is returned to the foreground :( Huge changes to my architecture after finding this out.

Upvotes: 0

Nader Dabit
Nader Dabit

Reputation: 53711

The base setup for building with Android and iOS are the same, but once you start getting into the development of your app, there are a few differences. From what I've experienced, we can probably bet on using about 80% of our code cross platform. I've heard of others using up to 90%, and I've normally heard the number being around 85%.

To use the code cross platform, you would just copy the code from your .ios.js or .android.js file, and copy it into the other. As long as there are not platform specific components, it should work.

Also:

  1. There are a few modules that were build specifically for iOS, and there are a few that were specifically built for Android, and some of them work cross platform. For example, ActivityIndicatorIOS (https://facebook.github.io/react-native/docs/activityindicatorios.html#content) is an iOS styled element, but if you look in the component itself, you will see both ActivityIndicatorIOS.android.js and ActivityIndicatorIOS.ios.js, so it should at least work cross platform, but UI will probably not be what you would be looking for in Android.

  2. If you install any plugins that need to access any native functionality, for example using a custom font, you will need to do a bit of work separately (on each platform) to get them working for each platform and it will not work cross platform.

  3. Bridging will be entirely different for each platform, though this may not be something you would even have to worry about unless you needed to do something that React Native does not support out of the box.

  4. To build in IOS, you will need a Mac and Xcode. To build in Android, you will need the android SDK and some type of emulator (I use Genymotion). But keep in mind that as of now, you can't develop iOS on a Windows machine unless you use something like ExponentJS, but if you have a Mac, you can develop cross platform.

Upvotes: 5

Related Questions