Xamarin iOS & Android APP

Hi,

I'm new in Xamarin, and I'm developing an application that will work on iOS and Android.

Right now I'm with some doubts. It will be an application of cooking recipes to a website that already exists. Basically the application will list recipes ... that are returned by a current webpage WebService.

I have some doubts about the architecture. To not always be calling the WebService I'm thinking create an internal database where I'm storing the categories, recipes ... The problem is to know when I go to the webservice to see if there are new recipes or categories. WebSockets is a good solution?

Another question I have, is that I have to download images, I store these images in a folder of the phone right?

Best Regards

Posts

  • nodoidnodoid GBMember, Beta ✭✭✭

    In no particular order

    When you download images you can store them on the device (device == phone, tablet, or whatever supports Android or iOS). Depending on the device depends on where you store them.

    Internal databases are very simple to do - SQLite is supported on Android and iOS and the SQLite component is available from the component store (personally, I don't use the component store one, but just build from source). Create the table depending on the structure the web service sends down and store internally.

    Both iOS and Android support WCF, JSON etc quite nicely so the web service aspect isn't an issue (WCF is an issue if you're using Java though). As to checking the web service you have two options

    1. Push notification (not hard to do but a bit of a faff, the service sends out a push notification, the app responds and downloads the new recipes)
      or
    2. Periodic check - simple to implement, check when the app is fired up or the user requests it.

    The UI is a simple enough affair. On iOS, this would be perfect for either a Monotouch.Dialog or custom UI using a NavigationController to move back and forth between recipes. On Android, while there isn't a NavController, it's simple enough to implement, failing that, a custom list will do the job.

    Your issue with this is ensuring you don't have a race condition between grabbing the new data and outputting to the UI. Have a look at the async calls; they will help.

    HTH

  • CheesebaronCheesebaron DKInsider, University mod

    Are there any requirements of having the recipes being available immediately when the web service have them? Or is it OK if they appear next time the app is opened?

    Let's say it is a requirement. I see two ways to solve this:

    1. Push a notification when new recipes are available (they can be received in the background, without the user being notified, if needed).
    2. Poll when the app starts and poll while the app is started once in a while.

    When you have decided on which way to go, then you will need some way to store these recipes, or maybe just store often used recipes. I don't see a reason as to why synchronize a whole bunch of recipes to the device you will never even use. Take for instance AllRecipes.com they have over 50,000 recipes. This will simply take too long and take too much space up if stored on the device.
    Whatever you decide here, there are several tools to store stuff:

    1. SQLite
    2. Azure Table Storage
    3. Couchbase (they are working on an Android version)

    As for downloading images, I recommend some kind of cache for that. I know @redth has something in his GitHub repository (not sure how recent that is). You could take a look at how MvvmCross does it with its DownloadCache plugin.

  • OldRedthOldRedth USMember, Insider ✭✭✭

    I'm actually using https://github.com/koush/UrlImageViewHelper/ now. I just build the java project, add the .jar to a Xamarin.Android binding project (it doesn't need any special transforms) and it binds nicely.

    You could also look at Akavache...

  • nodoidnodoid GBMember, Beta ✭✭✭

    @cheesebaron - I have a feeling SQLite auto-compresses databases when it can. As for storing in a cache, probably the simplest way is to grab and resize to a smaller size and store

  • JooFerreira.2190JooFerreira.2190 PTUniversity ✭✭

    Thanks to all ;)

Sign In or Register to comment.