I always wonder how apps like Airbnb, Flipkart, and Swiggy update their UI on the fly. Even if I didn’t update the app, Flipkart shows different UIs during festivals, while Swiggy always changes its UI based on the device location.
How I implement this in my react-native-app?
Webview is the solution?
Kindly help me..
Thanks
There are multiple ways you can go about doing this.
One way would be to use WebViews as you've mentioned, this would make it trivial to change the interfaces as it's entierly controled in the servers. But the main issue with this approch will be performance and non native look and feel. These are the two main advantages of using React Native over hybrid frameworks in the first place and therefor, it wouldn't make much sense to use WebViews everywhere. But if there's a small slice of your application that updates regularly(ex - terms of service) you could use a WebView to do the custom views.
A more common way that's low effort would be to have all the code in place for the different looks, but use feature flags to toggle different views. This would work the same way that a dark theme would work. The amount of customization we can do this way is limited because we need to code everything ahead of time.
Another way is to use server driven UIs. With this approch, you will have a pre defined templates in the client that you them populate on run-time with data from the server. For a very simple example, you could have a header image that could be populated with a seasonal greeting image. But instead of simple things like images, this can be much more visible chagnes as well. (ex - List view instead of Grid View)
One more involved way would be to use code push. This would allow things like seasonal UI changes. But this requires a lot more setup and might not provide the best user experience.
Webview is best because this way you can change the UI and the business logic or UI handling logic.
But you have to develop a minimum architecture for that.
Here is my way.
Develop Host layer to use camera, shared preference, file system etc.
Develop a communication layer which will be responsible for communication between your webview and the host layer so that your webview can access all the required device platform(eg. android or ios) features which can not be normally accessed directly from webview.
So now you can render whatever UI(by HTML and CSS) you want, you can put whatever logic you want via javascript also now you can access all the required device features you really need.
So, now you are the king of your app.
Just you have to keep updating the UI or logic in server when you really need.
Some cons are there like
webview in android is different than our normal browser. Some required features are not available.
Its behaviors is different in different API level. So you have to test it very well. For testing, you can use Genymotion.
It does not work well in some old devices/APIs.
Look and feel really matters. But smart design can fix that problem.
If you want your whole app in a single webview then you have to compromise with page transition feature of android or ios. But again smart animation design will fix that.
But this is just a working solution not a smart solution for server driven UI.
I have used some server driven UI frameworks. But they seems to be overhead and lacks some features.
So there should be a framework by which we can render native UI dynamically from server with corresponding business logic change feature and accessibility of all the possible device functionalities.
A few months before I started to develop a Server driven UI framework. I did it little bit. But due to lack of time I really could not complete it.
If someone interested to contribute in this project feel free to contact with me.
I have a solid idea and architecture for this project.
This framework can create a revolution in the world of app development.
email: bedmad82#gmail.com
Related
I'm planning to create a BLE (Bluetooth Low Energy) mobile app for both iOS and Android devices. (iOS 11 or above / Android 6 or above)
I and my friend used both Java and Swift.
Although we searched about Xamarin or PhoneGap App,
we wanted to use our previous working environment (Xcode/Android Studio) as possible, not spending time on learning new tools.
So we want to work on a BLE app and we want to make it work on both Android and iOS. Currently, we are making the same thing using Swift and Java.
Since the UI part overlaps for both platform, we wish to ask these questions, please.
If we use Swift and Java separately, we noticed that when a picture is changed, we have to update both to each separate code.
For example, we wanted to change the round button to a square button shape. Currently, we upload the same picture to the GitHub repository respectively. So we felt something is not efficient and we want to ask is there a better way to change both sides of the app.
Solutions which require prices, like adding Amazon Web Service S3, is also welcomed.
We are creating the same UI for both platforms using Swift and Java. Since the UI, button, etc (the interface parts) overlaps for both app, is there a way to code the same UI so both of us don't have to spend time for working the same thing?
Maybe something like Xamarin could be one way, but I want to hear various advice, please.
Why not just put the images in a common folder in source control that both builds can access it? That's the common way of doing it. Using S3 (or any other server) will work if you want to download it at runtime, but since you tried checking it into source control it seems like you want it part of the build.
As for the UI- native Android and iOS have completely different UIs and ways of working with it. Really unless you want to go with an html app, you're going to write two different UIs. The UIs are the least sharable part of a mobile app. At least for business logic you have a few options (worst case you can always use C, which runs on both).
I'm about to start developing my first Android application, I have been reading through the developer documentation, but am unclear on how user interactions are handled.
As a front end developer, I use alot of css/jquery to create rich and interactive user interfaces.
I see that Android has it's own version of stylesheets, which seem pretty straight forward, but I am left wondering how I can replace something like js/jquery. Is it possible to use JQ mobile for native Android apps? Is there a replacement to this? Does android's UI handle this?
I'm a little confused.
Yes, it is still possible to heavily leverage your js/jquery skills and create a solid Android application that provides a rich user interface which is primarily js.
This will obviously depend greatly on what kind of application you're writing however if you own a website that delivers rich web content to end users and you'd like to replicate this in an Android application then you should take a look at webviews. They should support most of what you're trying to do in js or JQuery and it would be a quick process to mock up a test app to see if it meets you needs. I have run into a few quirks when replicating some interactive d3js visualizations which required extra tweaking before working properly on mobile devices.
I expect these minor issues will be ironed out in the next few releases of Android. Kitkat is going to include webviews that are based on Chromium which will include an updated version of the javascript engine. Your best bet is to just test it out, the amount of Java code required for a mock application is quite minimal.
I am currently developing a native android app. My app has a lot of activities. I want to develop native android app. But in some case, I want to use a webview where the entire layout is just a webview. Not linear or relative or another layout, just a webview. All of the images and other things running in HTML. All of screen will run in HTML5.
So, I can partially transfer my app into iphone app or other platforms. This is the benefit of this way to me.
But I don't know. Is this way better? What will the performance be? What is the disadvantages of converting to an HTML5 app?
Can you explain?
There is a very good presentation about this very topic.
Performance: You are adding an additional layer in between, A webkit engine cannot always match native (and sometimes hardware accelerated) rendering performance.
Disadvantages: One is that the API use is limited, you can bind a page's JavaScript to Native code, but not all functionality is available.Though you might want to have a look at capabilities of Cordova project. Another is that emulating complex widgets via JavaScript will slow down the page.
Portability: Indeed is a great advantage, that's why PhoneGap and Cordova are popular. Though many like Facebook App etc have switched to native App for better performance.
The approach you require actually depends on your requirements. This may be my personal rant but IMHO: a markup can be only twisted so far, it can't out-perform industrial grade GUI programming setups as of yet.
Cons WebView
Can't use full performance of device, Since web view form an extra layer.
Web view can't listen all user event.
You can't fully share or save data from your web view to app.
Take more time to load. Other we get all things in a simple API and can be rendered.
Changing a simple fields in page need to load full page again.
Online required, can't extend offline features.
Orientation changes and full screen make difficulties.
Pros of using Web view
One page for both android and IOS.
I think the main advantage is the ability to make changes without the need for each user to update the app on his device, because all the pages are on your server.
No wait for app store approval for updation.
Some Techniques
Native elements TOGETHER with WebView. I think it will be much better, as there are a lot of functions that can't be done with WebView only. The combination of the two is much more recommended.
Rendering from locally, Create an assets directory for HTML files – Android internally maps it to file:///android_asset/ (note singular asset). So you can feed your web view form locally even if you are offline.
I think -by using this way- your app quality will be weak and app will be hard to use because the webview object not having a lot of tools that you can make it be compatible with android. e.g you can't share or save data from your webview to app. whatever that reference on your app what need and what dosen't need, by the way i tried to develop an app with html but it was bad.
I have android application that is written "regular" way. layouts, java, APK.
Now, depending on some factors I want data to be presented differently to different users with different preferences, etc. Doing it using XML layouts will be very problematic in couple of reasons:
Upgrade issue - we have bunch of users and they not good at upgrading.
Hard to maintain and code.
So, I'm toying with idea of "templates" where we can serve templates from server and just use device to generate those.
Web app won't work because our data available offline in case there is no connection.
There is buttons and stuff that user can press to call regular Activities and do things.
I envision something like:
HTML 5 template with {tags} that I will populate from data. I will receive tempaltes and data separately from server. I will merge that data and display on UI.
Now my question is how do I:
Display HTML5 inside Activity
Intercept button push in HTML in my Java code?
Is this bad idea to write something like this?
It sounds reasonable to me. You can use a WebView for displaying the content. Your app can manage a cache of downloaded templates and other content and display it in the web view either from the web site or from the cache if offline.
I think your objections to layouts are offbase. You really might be better off with layouts. Here's why:
Your app can be set to auto-update by users if you do not change permissions. But pushing updates to your app will remain an issue unless your app is entirely web-based. (not a bad approach by the way) But so long as you have a native app, you will need to push updates from time to time.
And as far as being hard to maintain and code, layouts are specifically designed to make this type of customization manageable. You can break pieces of the layout common to different settings into separate files, and add them with includes.
You can use fragments to adapt to a variety of form factors.
You can serve up different layout based on screen size, language, orientation, or any of a wide variety of variables.
Check out some of the series on layout tricks, and get more familiar with being a layout power user. I think in the long run it will save you a lot of effort, assuming you don't switch to making your app a web app instead.
http://android-developers.blogspot.com/2009/02/android-layout-tricks-2-reusing-layouts.html
http://developer.android.com/resources/articles/layout-tricks-merge.html
http://android-developers.blogspot.com/2009/02/android-layout-tricks-1.html
http://www.curious-creature.org/2009/03/16/android-layout-tricks-4-optimize-part-2/
Google: Android Layout Tricks.
Great stuff.
Another benefit: Compiler checking. No broken functionality because a variable or field has the wrong name. Not the case with HTML.
Another benefit: works offline too with no messing around.
And last - you will have a non-trivial amount of work attempting to get this hybrid HTML stuff working the way you want, and then have a very unusual and custom code base that nobody here on Stack Overflow will be able to help you with. Stick with Layouts and there are lots of experts who can help you tackle the stickiest layout puzzles.
ladies and gentlemen!
Very often on my job I meet the following requirement from the client, when developing android applications: "make it look like and iPhone app".
Yes, I know, that the best way is to offer him canonical Android design with all these patterns like dashboard, using menu button etc... But sometimes this is not the case, as instead, I have to make it look and animate just the same. It's frustrating.
Can you guys, please advice me an android library (if there is one) with iOS-like UI elements? Many thanks in advance, I'm looking forward to hearing from you!
To expand on Martyn's comment, which I agree with.
Perhaps there is a great reason why a client would ask for this, but in many cases I bet they might benefit from being challenged on this requirement. If I was presented with this request, I would first ask "Why?". Perhaps they'd answer as follows:
we need a consistent experience across platforms, or
it will be more cost effective to design once and apply to each platform, or
it doesn't matter why, just do it!
Here are some responses for each:
each user will generally have one phone, and won't require the experience on Android to be identical to iPhone - they only care that it works and looks great on their phone. In fact, an Android user would prefer if you used the UI patterns that are more common to the platform, as opposed designing to match iOS. Likewise for an iPhone user.
we have found that having a designer create a set of creative for iOS allows us to pretty much use the creative as-is for Android. Even though Android might have Tabs on top, versus bottom, we are still able to take the backgrounds, button styles, fonts and color schemes from one platform to the next. There will be slight differences, but overall the brand and look should translate well. Here is an example of porting a single creative design across platforms: http://daleburgosdesign.com/
if they answer in this manner, you might want to consider passing on the job. Pixel perfect matching across platforms is tricky aside from the ideas offered in previous answers (OpenGL and the use of a WebView - via Macarse). If the client can't provide good reasoning for this tricky requirement, then it might be best to search for your next client.
Not a straight forward answer to your question, but I hope you find it helpful!
There is no iphone UI library for android that I know of. What you can do is, get the iphone GUI psd and redo it for 3 sizes of android (for the 3 size ranges) and use the elements of these psd's to theme your application.
I get these kind of similar requirements. Sometimes it wont be much about the looks but about the navigation flow of the application and how new views or activities are animated. From my experience, there is no easy way to do it. So I end up making a lot of adjustments and hacks to get the job done. And I over bill the client. :)
Btw you could also consider libraries such as Sencha Touch, it will look the same in all phones that use a webkit browser.
AFAIK there are no 'iOS-alike' widget libraries for Android.
Because of this, you could reasonably charge the client more for both development and support, thereby providing an incentive to stick with the standard Android UI design and principles.
There is no library to port iphone views to Android but if you are starting both applications from the scratch you have two possible approach to share views between both platforms.
First one is using WebViews and coding HTML, JS and CSS. This kind of app is called hybrid.
Second one is using openGL. You can do it directly or using a framework like cocos2d-x.
Depending on what you are willing to you should choose what to use.