Skip to main content

Windows Azure Mobile Services supports Android

I have a great news for people that develop application for mobile devices. Windows Azure Mobile Services officially support Android. Until now we had support for Windows 8, Windows Phone 8 and iOS.
From this perspective, in this moment Windows Azure Mobile Services support the most commons operating systems for mobile devices. You can use the same Mobile Service endpoint for different clients. This means that you can have only one Mobile Service that can be used by a Windows Phone 8, a iOS, Windows 8 and Android application in the same time.
If is your first time when you hear about Mobile Services you should know that is a service that provide support to create the backend of your application. Storage, tables, authentications, custom scripts, batch operation and many more are supported by default. This means that you can focus on your client application without worrying about the backend. Everting is exposed as a REST API and can be accessed directly using REST API of using client SDK (Windows 8, Windows Phone 8, iOS and Android).
When you create a new mobile service, you will be able to download a project that is already setup for your client. Depending on your client (Windows 8, Windows Phone 8, iOS or Android) different project can be downloaded. Because of this you can start using and integrate the Mobile Services without losing time on setup.
One thing that I really enjoy on Mobile Services is the SDK support for different environments. Even if Mobile Services endpoints can be accessed using REST calls, Azure team created SDKs for each environment. In this case, we have an Android SDK that can be downloaded from here (https://go.microsoft.com/fwLink/p/?LinkID=280125).
The first step to be able to use Mobile Services is to create a “MobileServiceClient” instance. This will be used to access all the services available on Mobile Services. When you create a new instance of this class, you will need to specify the url of your mobile service and the application key. All this information are available on Windows Azure portal or on the default application that can be downloaded when you create a new Mobile Service. Warning, don’t share your application key – using this key anybody can access your services.
MobileServiceClient mobileClient = new MobileServiceClient(“mobileSericeUrl”,”applicationKey”,this);
If you want to access a specific table from the backend you can use “getTable” method. The only thing that you need to know is the name of table:
… = mobileClient.getTable(“myTable”);
All the CRUD operation are supported over this table (insert, update, delete and select). In the next example we can see how you can select the rows from a table that have a column equal with a specific value:
myTable.where().field(“name”).eq(“tom”)
  .execute(new TableQueryCallback<MyItem>() {
public void onCompleted(List<MyItem> result, int count, Exception exception, ServiceFilterResponse response) {
// custom code
}
});
As we can see, it is pretty simple to access any kind of resources from Mobile Services. On the backend we can define custom scripts that can run before a CRUD operation is execute over the tables. This custom scripts are defined in JavaScript.
The authentication of the user is already supported. Different identity are supported like Google, Facebook, Microsoft account, Twitter. Before using them we need to configure the identity provider on the backend. Is pretty simple, we only need to add the key and secret key for each identify provider.  For this, Windows Azure team created a page where we can add this information.
After we make this configuration we can specify for each CRUD operation over each table what kind user can access it. On the client when we want to request the user to login we need to call the login method of MobileServiceClient and specify what kind of identity we want to use.
mobileClient.login(MobileServiceAuthenticationProvider.Google, new UserAuthenticationCallback() {
new UserAuthenticationCallback() {
  …
}
  });
From the moment when a user is authenticated, every time when a request is made to Mobile Serivces, the user identity information will be send.
What I liked when Mobile Services were launched was the support for push notification not only for Windows 8 and Windows Phone 8, but also for iOS. Of course we have support for Android application also.
To be able to use push notification on Android devices you will need to use Google apis to push data. After you create an account, you will need to enter the api key in the push tab of Mobile Services portal. On the client application you can use your Google apis as you normally do.
From Mobile Services backend you will be able to send push notification from different location. For example we can send a push notification to our client when someone insert an item in table.
function insert(item, user, request) {
    request.execute({
        success: function() {
            request.respond();
            push.gcm.send(item.channel, “New data available”, {
                success: function(response) {
        // …
                }, error: function(error) {
  // …
                }
            });
        }
    });
}
As we can see, from now we can create Android application that use Windows Azure Mobile Services very simple. From now, when we need to create a backend for a mobile application that have support for different platform we should really take into account Windows Azure Mobile Services.

Comments

  1. i am getting following exception .
    com.microsoft.windowsazure.mobileservice exception

    how i will solve the problem please tell me

    ReplyDelete

Post a Comment

Popular posts from this blog

Windows Docker Containers can make WIN32 API calls, use COM and ASP.NET WebForms

After the last post , I received two interesting questions related to Docker and Windows. People were interested if we do Win32 API calls from a Docker container and if there is support for COM. WIN32 Support To test calls to WIN32 API, let’s try to populate SYSTEM_INFO class. [StructLayout(LayoutKind.Sequential)] public struct SYSTEM_INFO { public uint dwOemId; public uint dwPageSize; public uint lpMinimumApplicationAddress; public uint lpMaximumApplicationAddress; public uint dwActiveProcessorMask; public uint dwNumberOfProcessors; public uint dwProcessorType; public uint dwAllocationGranularity; public uint dwProcessorLevel; public uint dwProcessorRevision; } ... [DllImport("kernel32")] static extern void GetSystemInfo(ref SYSTEM_INFO pSI); ... SYSTEM_INFO pSI = new SYSTEM_INFO(...

How to audit an Azure Cosmos DB

In this post, we will talk about how we can audit an Azure Cosmos DB database. Before jumping into the problem let us define the business requirement: As an Administrator I want to be able to audit all changes that were done to specific collection inside my Azure Cosmos DB. The requirement is simple, but can be a little tricky to implement fully. First of all when you are using Azure Cosmos DB or any other storage solution there are 99% odds that you’ll have more than one system that writes data to it. This means that you have or not have control on the systems that are doing any create/update/delete operations. Solution 1: Diagnostic Logs Cosmos DB allows us activate diagnostics logs and stream the output a storage account for achieving to other systems like Event Hub or Log Analytics. This would allow us to have information related to who, when, what, response code and how the access operation to our Cosmos DB was done. Beside this there is a field that specifies what was th...

Cloud Myths: Cloud is Cheaper (Pill 1 of 5 / Cloud Pills)

Cloud Myths: Cloud is Cheaper (Pill 1 of 5 / Cloud Pills) The idea that moving to the cloud reduces the costs is a common misconception. The cloud infrastructure provides flexibility, scalability, and better CAPEX, but it does not guarantee lower costs without proper optimisation and management of the cloud services and infrastructure. Idle and unused resources, overprovisioning, oversize databases, and unnecessary data transfer can increase running costs. The regional pricing mode, multi-cloud complexity, and cost variety add extra complexity to the cost function. Cloud adoption without a cost governance strategy can result in unexpected expenses. Improper usage, combined with a pay-as-you-go model, can result in a nightmare for business stakeholders who cannot track and manage the monthly costs. Cloud-native services such as AI services, managed databases, and analytics platforms are powerful, provide out-of-the-shelve capabilities, and increase business agility and innovation. H...