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(

ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded

Today blog post will be started with the following error when running DB tests on the CI machine: threw exception: System.InvalidOperationException: The Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer' registered in the application config file for the ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information. at System.Data.Entity.Infrastructure.DependencyResolution.ProviderServicesFactory.GetInstance(String providerTypeName, String providerInvariantName) This error happened only on the Continuous Integration machine. On the devs machines, everything has fine. The classic problem – on my machine it’s working. The CI has the following configuration: TeamCity .NET 4.51 EF 6.0.2 VS2013 It see

Navigating Cloud Strategy after Azure Central US Region Outage

 Looking back, July 19, 2024, was challenging for customers using Microsoft Azure or Windows machines. Two major outages affected customers using CrowdStrike Falcon or Microsoft Azure computation resources in the Central US. These two outages affected many people and put many businesses on pause for a few hours or even days. The overlap of these two issues was a nightmare for travellers. In addition to blue screens in the airport terminals, they could not get additional information from the airport website, airline personnel, or the support line because they were affected by the outage in the Central US region or the CrowdStrike outage.   But what happened in reality? A faulty CrowdStrike update affected Windows computers globally, from airports and healthcare to small businesses, affecting over 8.5m computers. Even if the Falson Sensor software defect was identified and a fix deployed shortly after, the recovery took longer. In parallel with CrowdStrike, Microsoft provided a too