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(

Azure AD and AWS Cognito side-by-side

In the last few weeks, I was involved in multiple opportunities on Microsoft Azure and Amazon, where we had to analyse AWS Cognito, Azure AD and other solutions that are available on the market. I decided to consolidate in one post all features and differences that I identified for both of them that we should need to take into account. Take into account that Azure AD is an identity and access management services well integrated with Microsoft stack. In comparison, AWS Cognito is just a user sign-up, sign-in and access control and nothing more. The focus is not on the main features, is more on small things that can make a difference when you want to decide where we want to store and manage our users.  This information might be useful in the future when we need to decide where we want to keep and manage our users.  Feature Azure AD (B2C, B2C) AWS Cognito Access token lifetime Default 1h – the value is configurable 1h – cannot be modified

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