Chapter 8. Web Services with Push Notifications

Modern mobile applications are defined by their network connectivity. A mobile app that does not interact with a web server is both a rare find and potentially a boring application. In this book, we'll use the Windows Azure cloud platform to implement a server-side backend for our XamChat application. We'll use a feature called Azure Mobile Services, which is an excellent fit for our application and has the benefit of built-in push notifications. Once we are done with this chapter, our XamChat sample application will be much closer to being a real application and will allow its users to interact with one another.

In this chapter, we will cover:

  • The services offered by Windows Azure
  • Setting up your Azure account
  • Azure Mobile Services as a backend for XamChat
  • Creating tables and scripts
  • Implementing a real web service for XamChat
  • Using the Apple Push Notification service
  • Sending notifications with Google Cloud Messaging

Learning Windows Azure

Windows Azure is an excellent cloud platform released by Microsoft in 2010. Azure provides both Infrastructure as a Service (IaaS) and Platform as a Service (PaaS) for building modern web applications and services. This means that it provides you with access to direct virtual machines within which you can deploy any operating system or software of your choice. This is known as IaaS. Azure also provides multiple platforms for building applications such as Azure websites or SQL Azure. These platforms are known as PaaS, since you deploy your software at a high level and do not have to deal directly with virtual machines or manage software upgrades.

Let's go over the following more commonly used services provided by Windows Azure:

  • Virtual Machines: Azure provides you with access to virtual machines of all sizes. You can install practically any operating system of your choice; there are many premade distributions to choose from within Azure's gallery.
  • Websites: You can deploy any type of website that will run in Microsoft IIS from ASP .NET sites to PHP or Node.js.
  • SQL Azure: This is a cloud-based version of Microsoft SQL Server, which is a fully featured RDMS (Relational Database Management System) for storing data.
  • Mobile services: This is a simple platform for building web services for mobile apps. It uses SQL Azure for backend storage and a simple JavaScript scripting system based on Node.js for adding business logic.
  • Storage: Azure provides blob storage, a method for storing binary files and table storage, which is a NoSQL solution for persisting data.
  • Service bus: This is a cloud-based solution for creating queues to facilitate communication between other cloud services. It also includes notification hubs as a simple way for providing push notifications to mobile apps.
  • Worker roles: A simple way to run a custom process in the cloud can be a plain Windows executable or a .NET worker role project.
  • Cloud services: This is a conglomeration of other services. Cloud services allow you to bundle multiple services together and create staging and production environments. It is a great tool for deployment; you can deploy changes to staging and swap staging and production to preserve uptime for your users.

Apart from these services, there are many more and new ones are added pretty regularly. We will use Azure Mobile Services, which leverages SQL Azure, to build our web service for XamChat. You can visit http://windowsazure.com for a full rundown of pricing and services offered.

In this book, we chose to demonstrate a solution using Windows Azure as a backend for XamChat, since it is very easy to use with Xamarin applications due to the fantastic library in the Xamarin Component Store. However, there are many more choices out there besides Azure, which you may want to consider. Xamarin does not limit the types of web services your applications can interact with.

Here are a few service providers commonly used for mobile applications:

  • Parse: This service provides a product similar to that of Azure Mobile Services, complete with data storage and push notifications. You can get more information at http://parse.com.
  • Urban airship: This service provides push notifications for mobile apps across multiple platforms. You can get more information at http://urbanairship.com.
  • Amazon web services: This service is a complete cloud solution that is equivalent to Windows Azure. It has everything you need to deploy applications in the cloud with total virtual machine support. You can get more information at http://aws.amazon.com.

Additionally, you can develop your own web services with on-premises web servers or inexpensive hosting services using the languages and technologies of your choice.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.61.142