I wrote my app using native method, currently I want to use reactive native in our further development to avoid writing two copies of code for iOS and Android.
The problem is we can't completely rewrite all the code, we want to replace the project piece by piece.
So I am wondering if I can write some views of my project using reactive native and others remain native code that we have used a long time.
If this is possible, is there any existing tutorial about how to do this?
You can keep your originally written native code via native modules. You can port your current project pieces by pieces to native modules, then let React-Native have access to it.
I guess best option is, start a new React-Native project and make it access your native modules, you won't have to rewrite everything then.
Here is more info for Android and iOS
There is official documentation to this. Checkout:
https://facebook.github.io/react-native/docs/integration-with-existing-apps.html
Related
I want to make an android app using Kotlin for the back end and Android Studio. For the front end, I understand that React Native would be a powerful choice, however I cannot figure out how to add ReactN to my Kotlin project.
I also tried creating a project in ReactN and then adding Kotlin: installed nodejs, npm and create-react-native-app, made the project. Then I tried opening it in Android Studio, but I wasn't getting any options to actually compile and run the project. So another question would be: can you work on ReactN projects in Android Studio or not?
If you could give me some resources on how exactly to do this, or if you can walk me through it step by step, it would be very helpful. I want to mention that I've never developed for Android or Web before (I'm mentioning about Web because I cannot rely on any Reactjs knowledge from Web dev).
React Native is whole framework, for front and back end, and have nothing to do with Kotlin (well, some Kotlin snippets may be integrated into RN app, thats all). RN projects are in fact multiplatform web/js based apps and Kotlin is used for writing pure Android apps, so this isn't a front/back end separation in here, these are just different approaches to development. Mixing both, while possible, makes no sense in most cases
What i want to achieve is something like creating my own SDK like what react-native-fbsdk or rn-onesignal-sdk provides , so that those functionalities can be implemented in the react native project.
Basic questions :
Where to start from? Like what are the pre-requisites?
Native coding is required i believe for this functionality?
Any explanation or any such experience in such would be of great help .
Where to start from? Like what are the pre-requisites?
You can use a template like this one. It includes an example project which is basically an app that you can use to test integration of your native module and to quickly iterate on it.
Native coding is required i believe for this functionality?
Only if you need to use platform-specific functionality, or provide bindings to some pre-existing native library. Both examples you mentioned do exactly that – because they have native SDKs that can be used in non-RN apps, and they provide React Native bindings for them.
If your library is just business logic + some networking, and you don't intend it to be used in non-RN apps, you can do it all in JS. No need for native code. If you choose to go with the template that I have linked above, there are instructions how to use it to create a pure JS React Native library.
I'll be happy to update my answer if you can share some concrete requirements of what you want your SDK to do.
I have an application developed with ReactNative but now my client wants to get rid of it and go native in Android and iOS, I got the native code that RN generates for both but it is strongly tided to RN libraries, is it a good idea to continue like this and try to re-use the code or it's better to start over from zero with native code?
You could re-use some of your code, but I would advice against this. It'll be easier to rewrite the whole app (2 times) than to try to decouple your code from react native's library.
Although, couldn't you convince your client to stay with RN? The problem that RN fix is the need to write your app twice, if you go on this path you'll take twice the time to achieve the same result, and you'll encounter some problems hard to debug if you are not comfortable working with Android and iOS' custom frameworks.
Does anyone have experience with NativeScript and can compare it to developing native apps, especially for Android?
I have read all these articles:
FIRST THOUGHTS ON NATIVESCRIPT
SECOND THOUGHTS ON NATIVESCRIPT
Introduction to Native Script – Is It Worth Your Time?
My Experience Developing with Telerik NativeScript
I know especially three of them may be outdated. But I want to ask all of you developers:
How is your experience with NativeScript?
Are there any Android-Components you cannot use? Which are these ones?
Is styling really so limited?
Do apps really look so different at runtime as in the mockup as in the pictures of the first article referenced above?
Does loading of native Android objects into JavaScript Code always work correctly?
Does NativeScript generate Java-Code for Android-Platform out of the NativeScript code I write?
Is it possible to modifiy this code if I want to use some native-only features? What if I want to make UI changes then? Do I have to regenerate the code and do I miss my native extensions then?
Very glad to see that you are evaluating NativeScript to eventually use it in present and future projects.
I'll try to condense answers to a few of the questions into one, as they really are mostly related.
Skipped.*
That depends on what has already been exposed through a custom view/plugin or module. The core-modules that every NativeScript app comes with contains the most basic of wrappers for both Android and iOS under a common API. There are plugins (nativescript npm modules) that provide additional wrappers on native android views (nativescript-telerik-ui for one, nativescript-carousel), most of which are created by the NS community.
As RexSplode mentioned before me - it's mostly the platform that imposes certain limitations. NS uses CSS to declare style, but you can also access the native components and manage their style and appearance programatically if what you need isn't readily available out of the box.
First I'd like to note that the first 3 articles you've linked are over a year old now, and trust me, NativeScript has evolved a lot since then. With all the available components (remember the npm modules I mentioned earlier?) there's a good chance that you will get a close to 1:1 similarity to a well-styled native Android mockup.
At build time metadata is generated for the Android/Java public API used in the project. When the JavaScript Engine (V8) fires up, that metadata is loaded into memory, prototype chains are constructed, and callbacks are attached, so that when you call new android.widget.Button(); in your JavaScript code, the proper virtual machine instructions will be called, and a native button will be created. Static methods are accessed similarly, check out the official docs to get a better understanding of how it all works.https://docs.nativescript.org/runtimes/android/advanced-topics/execution-flow
and 7., and a cont. of 2. Java code, or rather compiled Java code is generated whenever you wish to extend a native Android class that isn't available already in a module or in the native Framework. Extending classes is very similar to how you would do it in Java - you extend a class, and create new implementations of interfaces. That means that you won't have to open Android Studio to create a new class, build it into a native plugin and then add it to your project, since you can do it all in your NativeScript code using JavaScript/TypeScript. https://docs.nativescript.org/runtimes/android/generator/extend-class-interface
Disclaimer: I am on the NativeScript Engineering team
I investigated the Native Script a little and my colleague at work writes an app with it, so I can offer you a bit of information that I have.
1. skipped
There are limited amount of components you can use with native script out of the box. However, if you have a native-java developer who can write a wrapper for you - you can use everything.
It is limited to the platform you are using. Android itself has a lot of style limitations which cannot be easily overwhelmed.
don't know
It works a little different. Your JS object, or rather widgets are translated to java code. So with the items from the box - yes, they are okey. If you write a wrapper for your custom component, then all is up to you.
Yes it does.
No, the code is generated, how are you going to modify it? Changes will be undone on the next build. However, you can write a native module for your application and use any features you want. It is like defining an interface, which you can use in JS code afterwards.
Is there any (easy) way to link to native libraries, specifically OpenCV, using Telerik NativeScript? I suppose since it outputs source I could go into the Android and ios projects after compiling and implement all of the openCV code seperately, but that sort of defeats the purpose of using NativeScript, imo.
Is there any cross-platform way to interface with native code?
Thanks!
If OpenCV supports Android and iOS then you would need to create the communication to the native code to use it. That's how all of NativeScript works, it allows you to use Javascript (TypeScript) and communicate directly to native code without any wrappers.
So essentially everything in NativeScript has a wrapper to the underlying native code/components, that's the difference and the power behind products like NativeScript and React Native as opposed to Cordova based apps (PhoneGap, Ionic, etc.).
Since your question isn't a code specific question, it's kind of hard to answer and there might be a slight misinterpretation on my part of what you are really trying to understand. Hope this helps in some way. :)
here is iOS pack for openCV:
https://sourceforge.net/projects/opencvlibrary/files/opencv-ios/3.4.3/opencv-3.4.3-ios-framework.zip/download
and for android you can download it from here:
https://sourceforge.net/projects/opencvlibrary/files/opencv-android/3.4.3/opencv-3.4.3-android-sdk.zip/download
EDITED:
a solution is to write a plugin and reference the OpenCV framework using cocoapods
here is the link of how to write a plugin in native script by cocoapods
NativeScriptUsingCocoapods