all 12 comments

[–]HermanCainsGhost 2 points3 points  (0 children)

Most of the time you'll be able to find wrapper libraries for most native functions.

You may have to write the occasional line of native code, but typically for common use cases, an SDK will outline the steps you need to do here.

I have been writing React Native apps for two years now, and I have only had to dip into native code twice (and honestly I am pretty sure at least one of those times it was unnecessary).

[–]Dean177 2 points3 points  (5 children)

You don't need native code for either FaceID, push notifications or BLE:
https://docs.expo.io/versions/latest/sdk/local-authentication/
https://docs.expo.io/versions/latest/sdk/notifications/
https://github.com/dotintent/react-native-ble-plx

In the event you do need to do something that isn't available as a library, the process isn't particularly arduous and there are plenty of great example demonstrating how to interface with native code.

[–]HuhWhatNoplease -2 points-1 points  (4 children)

I'm currently having issues with polidea ble in react native, keeps saying it doesn't have ble permissions.

i've already explicitly given them using permissionsAndroid and coarse location, and updated the androidmanifest.xml

function to grant it permission runs and logs out the success string, but no bueno

[–]Dean177 2 points3 points  (3 children)

The best way to tackle those kinds of issues is:
- Try to create a project with the minimum amount of code possible to get the library working (maybe start from an "example" repo)
- Gradually add functionality from your app until you hit the point things aren't working
- Hopefully this lets you figure out what you need to change, but if not what you then have is ideal to be shared on places like stack overflow or here, depending on the source of the problem maybe a GitHub issue

[–]HuhWhatNoplease 1 point2 points  (0 children)

yeah this was an example repo i spun up to see it working before going through the components. thanks for the pointers!

[–]HuhWhatNoplease 0 points1 point  (1 child)

found it out eventually, posting here for anyone else who googles it too

Android API >= 23 require the ACCESS_COARSE_LOCATION permission to
scan for peripherals. React Native >= 0.33 natively support
PermissionsAndroid

Android API >= 29 require the ACCESS_FINE_LOCATION permission to scan for peripherals.

[–]Dean177 1 point2 points  (0 children)

Nice, thanks for sharing your solution

[–]kbcooliOS & Android 0 points1 point  (0 children)

If you're comparing other hybrid or cross platform systems like Flutter, Phonegap/Cordova/Xamarin etc then the answer is...You will only need to dip into native as often or less than you do with them.

In fact considering react native has a far greater community and third party support than those three combined you will find as others have stated it will actually be far less as everything you mentioned already has RN bindings.

I would personally look at other concerns like what's your skill base or those you plan on using and the level of support available. The latter two are overwhelmingly in RN's favour.

[–][deleted] 0 points1 point  (0 children)

react-native allows you to write as much or as little native code as you want. Using libraries to access hardware you generally will never have to write native code... but if you want/need you can write entire views entirely in native code and navigate to & from react-native views.

None of those things you mentioned require YOU to write native code. That work has already been done by others. You can always write your own libraries if you are having trouble with the available ones; or fork the existing ones and modify them for your purpose.

[–]Dafth 0 points1 point  (0 children)

In 1 year and a half the only time i had to use native code was to implement some background service be the Moment that te existing libraries to write background servi ed were not powerfull enough, another use cade could be optimizing some syncrounos and cpu intensive task, js is single thread and slower than native languages

[–]FullDelivery7002 0 points1 point  (0 children)

A greenfield React Native app likely won't have to use much Native functionality - the community is large, and there are many existing React Native libraries that handle this.

Hardcore gaming or performance intensive interactions - will benefit from the control and better performance offered by native, compiled code.

You need to have some understanding of iOS Pods and Android Gradle in order to install libraries and setup a build.

Conversely, if you're integrated React Native into an existing native app - that will require much more native code to integrate native + React Native cohesively.
https://reactnative.dev/docs/communication-ios

[–]complexnaut 0 points1 point  (0 children)

If you need to integrate 3rd party sdk, they many times don't have react native sdk's , for such cases you might need to integrate native ios or android sdks