Is there a way to use ReactNative library in Android/iOS? - android

I worked on a React Native library and we build some native functionality like implementing BLE. So we did that in Android and iOS folders under React Native. Now we want to use the same functionality in Native project iOS and Android (Native). Reason we built in React Native is coz we have a different project thats in React Native. But now we are trying to use this library in native projects. We are not sure how we can achieve that.
We don't have anything built in this Library other than in Android and iOS folders under RN project.
Attaching image of how we build or functionality in React Native but under Android and iOS folders. (We can just copy pate and create a native library but trying to avoid that).

I don't think so. you probably have to separate them to 2 different libraries and publish them independently

Related

React Native app and importing native Android module

Since I did not get any answers from the previous post, I am posting again.
I have many experiences in Android native development but am a beginner in React Native. Wish to build a React Native app but need to find out these answers before I can start making architecture:
Is it possible to import a native Android module/ SDK (which is programmed in Java/ Kotlin) into React Native app? (I believe it is yes as I saw many good articles on the internet)
If I import the native Android module/ SDK to React Native app, does the app runs on iOS devices as well? Able to use APIs which native Android module/ SDK supports? (Or do I need a native iOS module/ SDK for iOS itself?)
I think this is similar to question #2. After importing the native Android module, does it also run on the web without a problem?
Looking forward to getting answers.
Many thanks,
Yes it is possible to integrate Android Native Modules.
No app doesn't run on iOS device if you have only Android SDK, You need to have a native iOS module to integrate iOS Native Modules.
For Web, I don't think so since both are native modules.
For more, please ref : native-modules-intro

A way to include android libraries in react native code

I have built an Android library that works perfectly fine with Android Applications when used as an AAR in an Android Studio project. Is it possible to use this same library in a React Native environment? If not, will it take a lot of effort to make this library compatible with React Native?
You can use this library to create library for React Native react-native-create-library
or
the official way to integrate Native Modules which will be found in
https://facebook.github.io/react-native/docs/native-modules-android
My answer is yes, it's possible, the android folder in react-native project is actually an android project, you can integrate a AAR lib here, make a function to invoke them, and call this function in .js file

Import Native ios/Android Code to Xamarin project

I need to import the native ios and android code in existing xamarin project same as react-native do for
ios : https://facebook.github.io/react-native/docs/native-modules-ios
android:https://facebook.github.io/react-native/docs/native-modules-android
is it possible to achieve in xamarin?
Thank you!
Unfortunately, I do not know how does the native modules work in React Native, however, there are Native Bindings that you could create and use in your Xamarin project.
Android:
Xamarin.Android supports the use of native libraries via the standard
PInvoke mechanism. You can also bundle additional native libraries
which are not part of the OS into your .apk.
iOS:
Xamarin.iOS supports linking with both native C libraries and
Objective-C libraries.

How are React Native modules different from Cordova plugins?

I was looking into comparison between Cordova based hybrid apps vs React Native and was confused how are React Native modules different from Cordova plugins?
(in case both are same, then why is FB reinventing the wheel)
Does React Native modules support all devices feature like Cordova does?
Thanks,
Rohit
How are React Native modules different from Cordova plugins?
React Native Modules and Cordova Plugins both perform the same task: they allow the calling framework (React Native or Cordova) to invoke specific native functionality which is not available by default in the framework.
As such, the native functionality provided by a React Native module may be the same as provided by a Cordova plugin, but they will have a different interface to the framework which sits above.
Therefore, it's possible to factorise out the common native code and have a native component which is made available as both a React Native module and a Cordova plugin.
For example react-native-background-geolocation vs cordova-background-geolocation.
Since only the interface to the native functionality differs, there have been some attempts to write a bridge to allow Cordova plugins to be used as modules in React Native, for example react-native-cordova.
The main difference is that Cordova uses HTML5 + CSS + JS for building hybrid apps. Your app will still run inside of webview. Although I've never worked with it, I can comment something
What does it mean?
I'm not sure about support of important features, like bluetooth, graphics, images (Core Graphics, Core Image), other core features
Performance also won't be the same as native app
React Native is different here, because all it does - translates your JS code into native code for platforms. The performance still can't be the same, but it's comparatively high.
Also, you can use native modules for your application in case you can't find one already created by others, so every feature accessible under platforms still be reached from React Native

Migrate existing Native Android project to Cordova-based project

I've developed Native Android project. I want to add Cordova's plugin interface between native and WebView components so i need to mix my project with Cordova-based project. Is it possible to migrate my existing native project with cordova-based project?
You can embed the cordova webview in your native project
http://docs.phonegap.com/en/3.5.0/guide_platforms_android_webview.md.html#Android%20WebViews
It is possible to do this, Cordova just runs as a webview and you could use Cordova on a specific page or part of a page in your native app.
However, you will get zero support to do this. With the new libraries of Cordova (since 3.*), Cordova uses the command line to build a web project and has a specific workflow to do so. The Cordova libraries are not optimized to do this.
If you do not have any UI in your existing project, or you want to replace the existing UI with webpages, you can create a plugin from your existing native code. Otherwise, I would not recommend to try to combine native and web that way with Cordova. You will have to do a lot of custom work to get it work the way you want to.
Another option is to create seperate apps and let them communicate with intents.

Categories

Resources