PhoneGap with Django Backend - ios

I'm working on a web application that uses django.
I would like to create a native application of the site for ios / android using phone gap.
Is this possible? As I understand native devices cannot interpret python code.
It is early in the project and if it proves too difficult I may go with a different framework I.e backbone.js.
Any thoughts / experiences?

That's right, you cannot run python code on iOS or Android using PhoneGap, but there is no need to do that. Yes, you can build a native mobile application of your site using PhoneGap.
I'll try to explain a bit how these technologies compare to each other:
Django is a python web framework running on a web server
PhoneGap is a framework for building native mobile applications using web technologies (HTML5+CSS+Javascript), the application will run on a mobile device
One common approach is to build the mobile UI with i.e. jQuery Mobile and use the Django web application to provide a RESTful API to get data to the application.
Take a look at this another question for more details.
Edit: Answer the question in the first comment
Yes, it's possible to build a fast and well working application with these frameworks. The performance with today's smartphones is more dependent on the quality of the implementation than i.e. jQuery mobile and Django in themselves.
Basically with PhoneGap there are three different ways for showing the content to the user:
server side generated pages
pages generated on the client side with Javascript usin data from the server, transferred in a predefined format using for example JSON
a combination of the previous two
This answer clarifies server-client communication and page rendering quite well.
You could use PhoneGap a bit like a constrained web browser, and basically show content directly from your server as you would when the user accesses the site with a normal web browser. But I don't recommend this, though. This approach has many downsides to it (i.e. what happens when the user opens a link from your website leading to another website?)
To be accurate, at least in my opinion, UI written with Javascript and running inside an app built with PhoneGap is not native. Comparing native applications and PhoneGap applications is another thing, here is one take on explaining the differences.
I don't know what kind of service you are building, but in general I'd suggest evaluating the different approaches before starting to build an application. Would a responsive mobile optimized web site do or is there real need for what an app can provide?
If you decide to build an app with PhoneGap, I'd suggest that you do it with client side Javascript and fetch the data from the Django backend with XHR requests in JSON format. There are lots of examples available in the internet.

Related

Xamarin.Forms and azure mobile apps with existing sql database

I have an MVC application in production, hosted on Azure. Now I would like to develop Mobile app using Xamarin.Forms and Azure Mobile apps. The goal is to use the same database on both mobile and web. After reading available documentation online, I haven't found the way that would suffice my needs. I would like to know what is the fastest and best way to achieve that.
Is it enough to add necessary fields to existing entities that I would use in my mobile apps? Meaning adding fields like: Version, CreatedAt, UpdatedAt, Deleted and add another Id field of type string ex. MobileId (because current database uses autoincrement ids of type integer). Is this approach Ok, or should I do it some other way?
Any suggestion/advice would be much appreciated.
Azure Mobile apps is an accelerator and a way for devs not familiar with backend development to quickly create a backend for mobile apps. Since you already have a backend, you can simply add API methods in your MVC app that your mobile app will call. You will not benefit from some of the features that the SDK provides but you won't have to change your database structure.
You don't need to create a backend mobile app and in most cases you probably shouldn't. Is your app hosted in app services? If so there really wouldn't be any major differences between leveraging (and expanding as needed) the controller layer of your application. In most cases the datastore won't need to change to accommodate a mobile app vs a web app. Usually you want the datastore to change and evolve based on the features that you want your application to support as opposed to the plataforms that are consuming those features. It's usually a good idea to add an abstraction layer(s) to shield the datastore from platform specific requirements.
That being said there are a few Azure services that you should consider adding to make your life easier when developing Xamarin apps:
Notification Hub (provides an abstraction layer over the platform specific push notification services for ios and android).
App center (provides very useful telemetry data about crashes and errors that occur in your Xamarin clients).
App insights, it provides really good additional telemetry data with very powerful out-of-the-box visualization and querying capabilities for both web apps and mobile apps (I would configure app center to feed its telemetry data to App Insights).
If you provide me with more details about the application I would be happy to give you more detailed suggestions but the recommendations above serve as a good starting point for almost all the mobile application projects that I have encountered.

Build entire iOS app as a website?

This might be a silly question, but wondering if I was able to build an iOS app completely in a UIWebview. Essentially not have one thing be native to iOS.
You can actually. There are several ways to use HTML5, CSS3, and Javascript to make mobile apps like iOS. You can use frameworks/programs like Cordova/PhoneGap. These frameworks/programs can let you use web languages and then compile it into an executable for the device. Something that can be submitted to the AppStore. Whether or not Apple accepts it thats another story. ;)
The other thing you can do is you want it to completely run off the web is you can essentially build a web app on a server like any other web app. However, you can put in CSS3 media queries and Javascript that can detect the size of the screen. Users can use their built in web browsers to access your site. If the screen isn't the right size, then you can redirect the user like if they try to access it with a laptop. With this method you can use server side scripting languages like PHP to do your computation processing. However, connection is required to the server and if a whole lot of people log in to your server, then the server can get bog down.
If you are interested in using web base languages for mobile applications, I highly suggest looking into PhoneGap/Cordova.

Django template for native ios application

I am designing the backend for an ios app with django. As I was learning django, I came across django template which is a major part of the Django MVC/MTV architecture. Most tutorial/books I come across explains django-template with respect to generating the html(view) of a Website. For native application for ios/android, do I need django template? Or should I just pass plain data(string) from my backend to the mobile device where my native application-code will parse through the string and will display data in respective views which have been created on the client side? Basically, how should I use django template for a django-ios backend-frontend project? Is it just an optional stuff?
If you are building a native app, then you don't need to use django templates, just build an API which your app will consume. It could send text data, or json or anything. And one you have an API in place, and want to offer your app on the web, then you could build a one page webapp that consumes the same API used by your native apps, so less work.

Calling Meteor from Native iOS Application

We are building an application that consists of a web app and a native iOS client. The web app is pretty straight forward with Meteor. But on the Native iOS App was wondering if someone can give us some pointers on the best practices for that app to call into meteor. I have seen that there is something like the collectionsapi api which exposes meteor collections over http, but am not sure how we would handle authentication for Native iOS clients if we used something like the collectionsapi or similar. Any pointers from some folks who have done this would be greatly appreciated.
Meteor's communication system is based on DDP (Distributed Data Protocol). You can access meteor's methods & make subscriptions to data which is probably the best way to go since you can get live data back too!
There is an objective-c client but its not been maintained : https://github.com/alansikora/objective-c_ddp-client
The ddp client was originally made prior to an official ddp specification (pre1). So you would have to adjust the client a bit to bring it up to date. Luckily its not too much work. The full DDP spec can be found here: https://github.com/meteor/meteor/blob/master/packages/livedata/DDP.md
Using DDP is a very attractive alternative to making a traditional REST request (POST,GET,PUT,etc). As the data on the wire is the same system meteor's client communicates to its server. So if you're able to make something on meteor work in a web browser you could pretty much replicate it on a native iOS client.
If you are still wondering about this, I've been working on a free, open source project that enables native ios clients to do meteor auth (SRP auth) and communicate via DDP. The project lives here: https://github.com/boundsj/ObjectiveDDP
There is an example app here: https://github.com/boundsj/ObjectiveDDP/tree/master/Example

Can we use Ruby on Rails to develop a mobile app?

Since Rails uses MVC architecture. I was wondering that if we can use Rails to develop a mobile app or any web app.
Out of MVC the 'M' and 'C' won't change to develop the mobile app right?
I mean the models and controllers will remain the same.
Only the view portion should be changed such that, instead of using html.erb files I want Java or Android SDK or whatever, to provide the UI for the mobile user.
Can someone enlighten me on this perspective?
Also I have been hearing about jRuby does it come into play for our mobile app development requirement?
The answer to this question is going to depend on how you want to deploy this app. Do you want it running completely on the phone or can it be a web app disguised as an iphone/android app?
For the native app solution I'd checkout the Rhodes Framework. It's not RoR but you'll see that it's an MVC framework that feels similar. This will allow you to build native iphone/android apps using Ruby.
For the 2nd option, web app disguised as a mobile app, I'd recommend Sencha Touch. Sencha has done an amazing job mimicking the look and feel of native iphone/android apps with their Javascript library. With this solution it would be just like any other web app though it's targeted for android and iphone via it's UI.
I've created an example rails / ember.js App that is exported with Phonegap. It uses just the usual MVC architecture of a Rails and an Ember.js App. Maybe you will find it useful. It also implements token authentication based on ember-auth and several OAuth strategies.
Currently in de the devel branch: https://github.com/joscas/base_app/tree/devel
Heroku deploy: https://starter-app-staging.herokuapp.com (the desktop version)
Exported with phonegap-rails gem (of which I'm also the author) for assets, fix paths etc.
Absolutly YES!
Ruby on Rails just a backend tech, is the same as what you plan to do for normal browser. There are only two things that you need to consider about mobile app. First is mobile browser's content size because you need to adjust your layout to fit the size. There is a HTML meta tag called viewport can help you.
Ex.
This script will tell user's browser that the content should be fit the devise size,initial-scale defines the viewport rate and maximum-scale defines how many times this page can scale, and user-scalble=0 means user cannot scale the page. More about viewport you can check the Mozilla's doc.
The other thing you need to consider is the HTML5 techs, but actually these aren't problems when you are using jQuery mobile. I recommend you to check their docs. This is very useful and clear for anyone.
RubyonRails is web application framework - it is running on server and user observer the result of application built on RubyOnRails inside browser(or Browser component), despite the fact that you can process on server just "M" from "MVC", and implement "V" and "C" fully on client side( in mobile browser).
In theory, you can fully deploy RubyOnRails application on client side( even RubyOnRails server and etc), but it will be rather expensive and hard, but it is could not be require in any rational project.
assuming:
There are two way you can choose:
Organize RubyonRails application on the server(process there Model), and process "V" and "C" on client side with any proper js libraries.
You can develop Ruby(not RubyOnRails application) - at least it is possible to develop for Android with JRuby.
Yes you can . Your view can be an web page/android/ ios application as view.
You may want to try jQuery Mobile (which is still in alpha by now) if it's just a matter of UI. If you need a tighter integration with your mobile, I don't think that running Rails would be efficient enough.
Try using React Native, the backend technology can still be Ruby while the front-end can use React Native to build mobile app both Android and iOS.
React Native

Resources