Don’t Re-Invent the Wheel: Use Components or Plugins In Your Apps

Xamarin provides native, cross-platform mobile application development using language we all know and love – C#. However, it is still required to learn concepts of each platform. For example to send text message (SMS) in all these three platforms there are different set of APIs.

Below API is for Android, which uses SmsManager to send the text message. There is another way to do this using Intents.

image 

In case of Windows Phone, ChatMessage allows us to declare and send text message. This API is available in WinRT platform. In case of SL based apps, we need to use Launchers/Choosers.

image

In case of iOS as shown below, there is no API as such. But we use URL to launch default messaging app. In this case, we cannot set the message body, which we want to send out.

image

Life will be much simpler if there will be just one API on all these platforms which will take care of sending text messages and as I developer we don’t need to bother about on which platform it is being called. Here comes components and plugins. My friend James has written a nice blog about ‘What Exactly is a Plugin for Xamarin?’. You can read it here

In our case, we’re going to use Messaging Plugin for Xamarin and Windows which allow us to use same API to send text messages. Below code is written once in a Xamarin.Forms project which depending on platform on which code is executing, send the message using that platform’s APIs.

image

Using this plugin, it becomes easier to send text messages on Android, iOS and Windows. And this is the magic of Plugins for Xamarin.

In future posts, we’ll cover some of the best plugins and components which can help you build cross-platform mobile applications with single code-base.

I hope you’ve enjoyed this.

Namaste
Mayur Tendulkar

//PUBLISH – Global Event Updates

Microsoft is hosting a global event //PUBLISH. This event is in series with //build, //learn and will be called //publish. You can find more information about this event at: https://publishwindows.com/ 

The idea behind this event is to help you get your apps in the store. If you’re working on any existing app (Windows Store or Windows Phone) or have an app idea, we’ll help you to complete it and submit it on the store. We at Pune User Group are happy to say that, PUG will be hosting this event in Pune. As this is a global event, we’ll be hosting it on the same dates i.e. 16th and 17th May. This post will give you idea about the event.

In Pune, you can find agenda and registration details here: Pune Link. Once you register, we’ll send confirmation mail to registered users and they’ll be invited for the event.

As it is going to be session+coding+support event, please make sure that your machine is properly configured. Please get the latest version of Visual Studio and Windows Phone SDK installed on your machine to avoid confusion at the venue. If you need any help with it, please contact us. My email ID is mayur.tendulkar {at} puneusergroup.org

And have I mentioned, there will be prizes too (for eligible candidates Smile)

Till then.. register and happy coding.

Mayur Tendulkar