Expo package with native code (objective-c and java) - android

It's common to run into situations where we need a third party library that uses native code. Examples: PayPal integration, access to the wireless system, etc.
The official answer for this is "you have to eject". Alright, everybody knows that I know that - no need to reply with this, please.
But there are expo packages that use native code. For example, the react-native-appearance.
So it is possible to create expo libraries that use native ios/android code. But I wonder how? I found no documentation about it. It seems to me that only the Expo core team knows about it because I only see this being used on packages developed by the Expo core team. Maybe I am not looking it right, but I found none, zero information on how packages like react-native-appearance are made.
Question:
How to create an expo package that contains native ios/android code (like react-native-appearance)?

Expo packages a whole bunch of Native Modules with the SDK, including react-native-appearance. If the Native code is included in the SDK, then you can use it, otherwise you might have to eject. Case-in-point, a hello-word expo app is much larger in size that a bare React-native-init hello-world app.

Related

will using Expo worst in react native?

I am new in react native. when i create react native app by :create-react-native-app My project name the project will create with some thing named Expo in it directory.
then when i run it in emulator it will running by expo and i having to see an app named Expo and i have to run my app by using that. Ok?
i did many search a bout Expo and saw that site, and many other sites and notes which were about Expo but i understood nothing, just Expo will make it Easy to run your app.
now i want to ask: if i use expo; will my clients have to use that for running my app on their devices??
and ask: will i have to pay money for some essential things in future ?(Given that i never want to pay any thing )
will Expo make my application depending on himself(Expo) and prevent me to use various APIs like google map or ?
and in last: using that or not? which way is more professional?
Firstly, welcome to the React Native community!
Most of these questions can be answered in the Expo FAQ
if i use expo; will my clients have to use that for running my app on their devices??
You can at any time detach your app from expo and publish it to the App Store or Android Play Store.
will i have to pay money for some essential things in future ?(Given that i never want to pay any thing )
From the expo FAQ page: "Expo is free.
Our plan is to keep it this way indefinitely.
Expo is also open source, so you don’t have to trust us to stick to that plan.
We might eventually charge money for services built on top of Expo or for some kind of premium level of support and consulting."
will Expo make my application depending on himself(Expo) and prevent me to use various APIs like google map or ?
Assuming you are talking about Native Modules.
Expo provides a very large API for building a native app.
Some known reasons you might detach are:
Using a companies Proprietary internal native API
Unsupported libraries like React Native Fetch Blob - this is currently being added to React Native but until then it is not available in Expo
If you do need to add custom Native Modules, you could always detach from expo. When you Detach you will get an ios, and a android project.
Lastly you could always recommend new features: https://expo.canny.io/feature-requests
and in last: using that or not? which way is more professional?
Using Expo will provide you with tested Native Modules on top of React Native, if anything this makes it more professional.
Here are some popular apps constructed with React Native.

Installing Realm with Create React Native App

While I'm trying to install Realm, I'm asked to edit some of the generated .java files for Android:
https://realm.io/docs/javascript/latest/#getting-help
However, Create React Native App hides the system level code from the user. Does that mean using CRNA is impossible, and I have to switch to straight React Native?
create-react-native-app has its own build scripts that depend on the platform specific code to be modified by Expo.
The whole idea of create-react-native-app is to stick to js. By sticking to js, you can take advantage of some pretty neat features such as running your app through the Expo Client or live developing on the web. They can do this because they can serve their static (I think it's pretty static) platform specific code everywhere.
This means you can't use any native code or even third party native code modules (such as react-native-camera) while using create-react-native-app.
From the docs:
Standard Expo projects don’t support custom native code, including
third-party libraries which require custom native components. In an
Expo project, you only write pure JS. Expo is designed this way on
purpose and we think it’s better this way.
If you would like to use native code and create-react-native-app, expo has a detach process that will reveal the platform specific code. You can check it out here.

If I have linux and a not perfectly functioning hackintosh, should I use reactnative or phonegap for building multiplatform (android, ios) apps?

I have the following considerations:
1.I will never use the hackintosh on a regular basis, maybe only for the final steps on xcode and publishing.
2.It could be that some functionalities i would like to realize cannot be done on phonegap/react native. I heard react native allows one to integrate native codes (e.g. android with java and ios with swift), but I'd like to reconfirm this.
3.I read that many people were complaining about errors with react native on linux even for android. Can someone perhaps tell me if they have already successfully built something with react native + linux?
4.I haven't spent much time on learning react native yet, so this last point might be silly, but if one already have build an android app with react native, how much work is there still to build ios? Also, do I HAVE TO use jquery for react native?
OK, I'll try and answer as thoroughly as possible, from the RN side (I've never really used cordova).
I will never use the hackintosh on a regular basis, maybe only for the final steps on xcode and publishing.
OK, RN works with all platforms. Of course, you will need xCode at one point to publish your app but apart from that everything can be done on other platforms. However, to build on iOS, you will need Xcode to launch the simulator or run you app in debug mode so you will need to work on a Mac.
It could be that some functionalities i would like to realize cannot be done on phonegap/react native. I heard react native allows
one to integrate native codes (e.g. android with java and ios with
swift), but I'd like to reconfirm this.
Yes ! RN allows the integration of native code. Check the docs here and here for more information.
I read that many people were complaining about errors with react native on linux even for android. Can someone perhaps tell me if they
have already successfully built something with react native + linux?
Can't help on this one but RN works with linux, especially the latest versions. Check this
I haven't spent much time on learning react native yet, so this last point might be silly, but if one already have build an android
app with react native, how much work is there still to build ios?
Also, do I HAVE TO use jquery for react native?
I have built apps for iOS and Android and have never used jQuery in any of them. Moreover, jQuery does not work with react-native as explained here
Finally, about 80% of the code (depending on apps of course) is the same between android and iOS. This leaves 20% to work on (usually not long modifications).
Hope this helps, but I strongly recommend using RN instead of phone gap.

Android app with HTML5

I want to create a Android Application.
Altough I want to use HTML5 for creating that application.
Later on I even want to get the application to multiple platforms like for Apple.
I have tried Eclipse but couldn't get it to work.
When I create a new "Project > Web > Dynamic Web Project" I can't export this into a Android Application.
PhoneGap looks interesting.
Although I'm not sure how you can create a .apk (for android) there.
Or should this work together with Eclipse?
Could anybody give me a headstart?
What Application should I use to make a HTML application?
How do I create a .apk file?
Thanks in advance.
If you really want to dive right into developing with Phonegap, you can try out Telerik's AppBuilder (http://www.telerik.com/appbuilder). The demo project uses KendoUI Mobile (which I can also recommend) is comprehensive enough for anyone. As far as I recall you can use it for free for up to 2 projects.
There is also Intel's XDK (http://xdk-software.intel.com/), which is completely free - but the simulator and deployment features aren't as far developed as Telerik AppBuilder's are.
I strongly recommend AGAINST doing it the "real way" with eclipse/xcode if you have no prior experience with developing native android/iOS apps.
Start with the following project:
http://code.google.com/p/html5webview/
This will give you a good start. You can download it and import it into eclipse.
Phonegap does create an APK.
Essentially what Phonegap does is present a WebView and a simple API for calling native methods on the respective platforms. This allows you to write the same app and deploy it on multiple platforms with minimal or no changes. The majority of what you would do in Phonegap is set up the projects to pull in the cross-platform libraries.
The major limitations come from lack of access to native UI components. As you progress in app development you may find that it's a significant limitation. I rarely build HTML5-based UIs anymore, and instead go with native apps.
There are other cross-platform frameworks out there as well. Here's an article describing some pros and cons of each:
http://www.developereconomics.com/pros-cons-top-5-cross-platform-tools/

Use Phonegap for SDK developement

I am developing a native SDK which is integrated into a native app ("host app"). The app is calling my SDK method and this method will open a Webview (both for iOS and Android).
I looked into Phonegap as a solution, and saw that it gives me a platform for opening a Webview and communicating with the device. While this is ok, I cannot find a way to build this as the "SDK app" that I wanted, triggered by host native app, without writing the native code for that myself (duplicating my code for iOS and Android and dealing with native code).
Does Phonegap (or other platforms) have the ability to add a native logic (and not only webview) without the need to duplicate my code?
tnx!
Yaniv
PhoneGap is for developing apps. It is not really for third parties to create a library for others to use. While you can try to twist PhoneGap (and similar solutions) to serve that role, that will add extra baggage for anyone who would want to integrate with your library.
Hence, I suggest that you just create a library, sans PhoneGap.

Categories

Resources