Corona for business app (non game)..

Hi Group,

I’m a web developer and I’m just getting into mobile phone apps. I’ve been warned that corona is great for games, but not business. My requirements are pretty simple. I need to connect to a web server or an internal business server, grab info, display it to the user and possibly allow the user to enter info that would get posted back to our business servers. I need to develop an app for both iphone and android.

In general terms, how does corona work in this situation? Is it hard to connect to a database server to get info?

I started developing an app with corona about 1 year ago and I seem to remember having a hard time finding documentation that would explain this.

Any info is helpful!

Thanks,

Chris

[import]uid: 51437 topic_id: 21110 reply_id: 321110[/import]

I am a fairly new Corona user, so I might not be the best person to answer how Corona could work for you.

But from my experience as a web developer, it seems like this is something that would just be better suited as a web app. Something you build on your server that you can then access on your mobile devices.

If you don’t want that front end on your server, you could actually just build the HTML front end that connects to the database server, and use PhoneGap to make it an actual mobile app.

While I like working in Corona, I am not sure if it would really be suited for you need. [import]uid: 17827 topic_id: 21110 reply_id: 83458[/import]

I am not sure what Corona can do in terms of hooking up to a remote database.

The approach I would probably take would be to write a web service for your data that outputs JSON and then read and display the data with Corona from there. Working with JSON and Lua tables is pretty simple.

As far as iOS goes I found Lua/Corona to be much simpler to work with JSON than Objective C was.
[import]uid: 112807 topic_id: 21110 reply_id: 83465[/import]

Corona has the tools to perform well on web based services. You can do regular http posts, json, xml, and make extensions to make them work with REST or SOAP services.

Also, it has some neat ways of displaying multiple web views that may also grab you attention. It also has built in support for getting information for databases via SQLlite and probably MySQL as well.

No, I don’t think you’ll have to worry about making web based applications at all. [import]uid: 49520 topic_id: 21110 reply_id: 83479[/import]

Well, I think they would need to make a web based application.

While Corona does have support for SQLite databases, unless I am mistaken (and I could be), the database needs to be local. Which means that in order to access it, they would need to download the database each time. And then upload it back to the server when the changes are complete.

That also means that only one person can work on it at a time since if multiple people start uploading changes, said changes will get overwritten.

And really, downloading a database each time is a really bad development scheme.

I think if they are going to use Corona, the best method would probably be JSON, though that will require web application work as well. And while Corona does have code to work with a variety of web services, the question really is Is there something in Corona that can make doing this easier?

Especially since the poster said that he (she?) is a web developer and could possibly already knows how to develop web applications using more traditional tools. [import]uid: 17827 topic_id: 21110 reply_id: 83500[/import]

Hi
We have developed several business apps with Corona SDK and together with HTTP GET and POST we communicate with remote servers and ASP.NET MVC and SQL SERVER 2008 for data retrieval and storing or data. We have also developed combined apps where most of the display objects is pure webviews and tabbars, camera integration, gps and more and native Corona.

Corona has the power to combine these two and to build for several platforms easy. I have tried both phonegap and titanium but found that Corona is much easier and better than the latter two.

[import]uid: 22737 topic_id: 21110 reply_id: 83529[/import]

I’ve developed a couple of “business” apps with Corona.
Since the widget library is out, corona is the best solution (IMHO) for most of the simpler business apps that require getting data from a server, parsing it and showing it in a table with some user actions.

I’m currently working on an app the works with several feeds (RSS, XML, Twitter and JSON) and shows them in several tabs and tables and allows the user to share the data on facebook/twitter/email.

I started the app using titanium and switched to corona. I’ve never looked back since :slight_smile: [import]uid: 13553 topic_id: 21110 reply_id: 83566[/import]

Hi!

I’m currently developing a business app that must retrieve, parse and store data from a database.
I have no experience dealing with database.
Do you know where I could find exemple code for this?

Thanks [import]uid: 25327 topic_id: 21110 reply_id: 83761[/import]

Michael,

For SQL in general, SQL course covers the basics very well:

http://www.sqlcourse.com/intro.html

Once you know a little SQL, you will want to look into the Corona specific implementations:

http://developer.anscamobile.com/content/data-storage

http://developer.anscamobile.com/reference/index/sqlite3

[import]uid: 112807 topic_id: 21110 reply_id: 83787[/import]

Hi PaulTech,

Thanks for the links! [import]uid: 25327 topic_id: 21110 reply_id: 83814[/import]

Hi PaulTech,

Thanks for the links! [import]uid: 25327 topic_id: 21110 reply_id: 83813[/import]

@michael.peiffer… and others. Most of the time, you are not going to be connecting your app directly to you online/corporate database. Most of the time you’re going to have some set of web accessible database controllers to access.

While you will see that Corona SDK can connect to an SQLite database, that database is local to your device and is used to store app/game data that your app/game needs on a constant basis. Think of it as local storage only. What you’re describing is access databases located elsewhere.

Now most database servers like MySQL MSSQL and others can be access via TCP/IP calls directly to their server port, and Corona SDK has good TCP/IP socket layer calls, lets face it, thats a lot of low level system programming that most of us don’t want to do.

What is easier is to use standard HTTP GET and PUT calls to a web server where some PHP, ASP or other web based data access scripts exist.

Locally in your app, you use the “network.request()” API call to request a script on your server that will connect to your database, retrieve the object and return the data is a well defined data format, like XML or JSON then you will parse that data and display it in your app.

I know this is a bunch of techno mumbo-jumbo

But it’s really pretty straight forward. Lets say you want to get a list of users between 18 and 25 in your database:

App does an network.request(“http://yoursite.com/getusers.php?minage=18&maxage=25”, “GET”, functionToRunWhenDataIsFetched)

You have a PHP script on your server called getusers.php and it takes some HTTP GET parameters on minage and maxage. It connects to your database, does the query and then puts all that information in a PHP array. The last line of that script does an:

echo(json_encode($userdata)); // assuming $userdata is the array of users…

When that request finishes, your app will automatically call a Corona function you wrote called “functionToRunWhenDataIsFetched(event)” and passes a table called “event” to it.

In that event table is an entry called response. So you end up doing:

local myUserData = json.decode(entry.response)

and now you magically have a Lua/Corona table of all your users all nicely organized for you.

You can then run a “for” loop over that data, shove it into a widget.tableView and voila - you have a business app.

As far as android goes, most of the current widget look is very iOS in style, but I think it works on android.

Rob
[import]uid: 19626 topic_id: 21110 reply_id: 83832[/import]

In general, unless it’s a MUST HAVE function, you don’t let user applications access the DB directly but go through an API/web access/php script that will contact the DB.

The main reason is security - you don’t want someone to decrypt your DB password and have full access to it, play with the app and mess your data etc.

The approach that robmiracle presented is the default, most common way of fetching data from a remote server although you could also download a sqlite file and use it locally.

You have to choose the right technology for the right applications.

If the local DB doesn’t change at all, a DB file might be the easiest approach. just fetch the new file every time you update the data and you don’t have to worry about dealing with updates.

On the other hand, if you need the info to be incrementally updated, I would use a local DB with a JSON feed that updates the data back and forth to the server.

if you supply some more info regarding the type of data, sources and how frequently are you updating the data, it would be hard to recommend the best method for the task.

Good luck,
Shahar

[import]uid: 13553 topic_id: 21110 reply_id: 83838[/import]

@Rob

Wow your post is exactly all I needed to get started with this. Thanks!

The app must download locally data, texts, images and videos from a server so that the user can use it offline.

Maybe I should use network.download to download XML data files and media files? [import]uid: 25327 topic_id: 21110 reply_id: 83840[/import]

Hi robmiracle,

Your suggestion on writing a business apps is really useful. I am new to corona and client server application. Would you mind to give us a example for how to access the remote database and display in the apps. It would be great if you can post a sample database in a server.

Thanks
Ken Kwok [import]uid: 58098 topic_id: 21110 reply_id: 89906[/import]

@michael.peiffer, in that case you are likely to get some XML or JSOn file from your database query that has the URL’s for the images and videos, then you would use the network.download() API call to fetch each of the downloadable items.

@kenkwokkam, I would love to post a sample, but to do so pretty much requires a full fledged project. It’s simpler than writing socket level code, but its still involved with lots of steps. It’s way too much for a forum post. Given my current work load, I’m not sure when I’ll be able to get to it.

[import]uid: 19626 topic_id: 21110 reply_id: 89915[/import]