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.
… = 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:
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.
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.
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.
i am getting following exception .
ReplyDeletecom.microsoft.windowsazure.mobileservice exception
how i will solve the problem please tell me