ios native app talking to an API or direct database connections? - ios

Folks,
Designing an ios application, and would like to confirm my strategy. There is a database (dynamo/mongo/etc) i am building up, which the app needs to make use of. Is it smart to front the database with an API, and have the ios app authenticate against the api.
This way the app makes calls to the api instead of directly to the database?
Would you suggest node.js be a good place to start crafting the web api with?
Thanks!

Yes, access the data via an API. Whether fancy authentication is needed, depends on what is stored in your database, and what your application is designed to do. Here is one resource (among millions) on API design: http://www.vinaysahni.com/best-practices-for-a-pragmatic-restful-api
Also, here is a popular networking library for iOS: https://github.com/AFNetworking/AFNetworking
As for what technology to use, that too open ended and you will get 10 answers for every technology available. This should help though: https://softwareengineering.stackexchange.com/q/154519/44948

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.

Apple swift - How can an app connect to existing heroku/S3 database

Im new to iOS and new to SWIFT with no previous experience with Obj-C. But, Im not new to Ruby. I have a web based app on heroku and am beginning to learn SWIFT so I can build an iOS counterpart. I need to wrap my head around the bigger picture before I can get started and I can not figure out how these apps connect to databases.
Can an iOS app connect to an S3 database...and share that database with a website? Is there documentation on this process that I have over looked.
Connecting an iOS app to a public database would really be a bad idea - all server logic should be implemented on the client, and you would also need to hardcode database user name and password in your app.
A better way is to create a server app exposing a set of REST APIs and being responsible of dealing with the database. This way you can better control at server side what the app client is able to do on the database.
If you have an order entry app, for instance, you can create APIs to:
login
register
create an order
modify an order
add a contact
delete a contact
etc...
Some of the advantages are that:
in case you need to update the logic (but not the API interface), you just need to update the server, whereas in your scenario you'd need to release a new version of the mobile app
you control and limit how client apps access to the data (preventing for instance a user to access another user's orders)
if you want to develop the same app in another platform (android, ...), you reuse the same APIs
To get started, I'd suggest you to read the AFNetworking tutorial on raywenderlch.com, focused on a ios networking library, but talking about JSON, REST, remote APIs etc.
Next you have to choose a server side technology - the most popular nowadays is node.js - to get started you can read other tutorials on the same website:
http://www.raywenderlich.com/61078/write-simple-node-jsmongodb-web-service-ios-app
http://www.raywenderlich.com/61264/write-ios-app-uses-node-jsmongodb-web-service
if you don't want to use node.js and/or mongodb... the same architecture applies, just languages and technologies differ. Just transpose what you learn from there.
If you want to read about other languages to use at server side, just google for it - if you want to use ruby, try with ios rest api server ruby.
Note: I made no mention of swift because your question looks more like an architectural problem than a language specific problem. The tutorials I mentioned here use objective-c, once you've designed an architecture and chosen the language at server side, you can start looking into how to call REST API from swift.

Azure Mobile Services - Data Access - Developing for both mobile apps and websites

I'm developing with Azure Mobile Services (using SQL Azure) to provide a backend for both IOS and Android mobile apps and a PHP website.
My question is now that now custom apis have been introduced is it considered best practice to wrap everything up in custom api calls rather than e.g. using the CRUD table operation scripts directly from apps or websites?
Additionally for data access from a website should you lock down access to stored procedures and only exec via custom apis, to enforce a consistent approach no matter who the consumer is?
While I appreciate that custom apis and the table scripts are restful it still isn't clear how to architect a solution in the most efficient, reliable way that can enforce business rules in only place allowing each process only one entry point e.g. you have a stored procedure exec'd by an api called from the mobile apps. If the website calls that stored procedure directly without going via the api it could have unwanted side effects because other logic steps will have been missed.
I'm relatively new to Azure so forgive me if I have just missed something fundamental here. I've read many blogs and tutorials but they rapidly go out of date.
Many thanks
In my opinion the great feature of azure mobile services is the push notifications (to ios, android, wp). If you are not going to use that, there's no great advantage to use WAMS
(Windows Azure Mobile Services).
But it's a good choice using Windows Azure as backend since it's easy to scale up /down. In this case, you could create a Webapi and host in a Web Role. As it works with http, you can easily create Restful services and call them from your apps (ios / android).

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

How to provide your app with a network API

I am going to write a Ruby application that implements a video conversion workflow consisting of multiple audio and video encoding/processing steps.
The application interface has two core features:
queueing new videos
monitoring the progress for each video
The user can access these features using a website written in Ruby on Rails.
The challenge is this: I want make the workflow app a self-sufficient application, not dependent on the existence of the web view.
To enable this separation I think that adding a network API to the workflow application is a good solution because this allows the workflow app to reside on a different server than the web server.
My question is: Which solution do you suggest for such a network API?
A few options are:
implement a simple TCP server and invent my own string based API
use some sort of REST api (I don't know if this is appropriate for this situation)
some sort of web-services solution (SOAP, XML-RPC)
another existing framework
Feel free to share your thoughts on this.
I would suggest two things:
First, use REST as your API. This allows you to write one core application with both a user interface and an API for outside applications to use.
Second, take a look at PandaStream. It's a Merb application that encodes videos from multiple formats into flash. It has a REST API, and there's even a Rails plugin so you can integrate it with your application. It might be a good example codebase, or even a replacement for the one you're trying to build.
Hope my answer helped,
Mike

Resources