Plugin - James Montemagno https://staging.montemagno.com/tag/plugin/ https://staging.montemagno.com/content/images/2017/08/MonogramIcon_Orange_NoBuffer.png Plugin - James Montemagno https://staging.montemagno.com/tag/plugin/ Hugo -- gohugo.io Tue, 13 Oct 2026 23:21:57 GMT 60 More Plugins for Xamarin: Vibrate, Device Info, Connectivity, & Battery https://staging.montemagno.com/more-plugins-for-xamarin-vibrate-device-info/ 598df8f2c121b60019bf301a Fri, 26 Dec 2014 23:04:54 GMT I hope that everyone has been having a wonderful holiday season. Over the last month I have had one large goal; to create a plethora of Plugins for Xamarin. This desire to create plugins started a long time ago when I created my very first NuGet packages for cross platform settings. Once I iterated on the plugin and saw how successful and helpful it was I knew right away that I wanted to create more, which is where the idea of a cross platform text to speech plugin came from. I didn’t stop there though as more ideas came to my mind and we even launched a holiday contest with awesome prizes for anyone who also wanted to create a plugin. Here is a recap of the last few weeks:

An Easier Way to Develop

Immediately I realized that setting up projects for iOS, iOS Unified, Android, WP, WP RT, Windows Store, and the PCLs was a big pain if you had to do it all manually, so I wanted to solve this. With a bit of hard work and help from @Kzu I was able to introduce brand new Visual Studio templates for creating plugins and nuspecs. This makes it so you are immediately productive with a full project setup so you can start coding.

Vibrate

Have you ever wanted to tap into the vibration feature of your mobile device from a common API? Well here it is, simply call Vibration(int milliseconds); and you are done! Simple and effective.

Device Info

When using Xamarin.Forms I really enjoyed that I could execute specific functionality by checking the platform type from a PCL or shared code. So why shouldn’t you be able to do this normally? Device Info was born and also brought to the table the ability to get firmware version, device model, unique Id, and more.

Image Circle Control Plugin

Next up was something a bit different; a control plugin for Xamarin.Forms. I really like circle images, I mean I really like them a lot. In fact, I keep talking about them on dates that I go on and I even blogged about them over on the Xamarin Blog. So the Image Circle control plugin for Xamarin.Forms was introduced so no one else would ever have to write code to create circle images from scratch.

Connectivity

Creating online/offline mobile apps can be a bit tricky and each platform has a different way of figuring out if the device has connectivity. So instead of writing this code over and over again I decided to take it to the next level and create a connectivity plugin so you could just check to see if there is an internet connection. Even better is that you can subscribe to be notified when your user is disconnected!

Battery Status

This plugin started as a fun little project on my plane ride from Seattle to Austin for the holidays and ended up with me coding, testing, and releasing this plugin on Christmas Day! Check the current batter percentage left, the devices power source, and of course register for notifications when anything changes.

I love plugins for xamarin and they don’t just work on iOS and Android they all work on Windows Phone and most work on Windows Store as well. I hope that everyone will find these useful and inspire you to create your own plugin. If you are interested to see how I created these be sure to see the entire source code on my GitHub!

Happy Holidays!

]]>
What Exactly is a Plugin for Xamarin? https://staging.montemagno.com/what-exactly-is-a-plugin-for-xamarin/ 598df8f2c121b60019bf301d Sat, 06 Dec 2014 18:39:04 GMT I am so glad that you asked! I recently blogged about creating reusable plugins for Xamarin.Forms, and it might have caught you a bit off guard. Does Xamarin.Forms or Xamarin itself have plugins? The short answer is YES with the power of PCLs and NuGet.

Component vs. Plugin

For a long time, Xamarin developers have been able to add rich functionality to their mobile applications by adding Components from the Component Store. While you might consider these “plugins” of sorts, let me define what a plugin means to me.

Component When refer to Components, we’re generally talking about a library for Xamarin.iOS or Xamarin.Android that has been packaged for the Xamarin Component Store - similar to how a NuGet is a Library that has been packaged for the NuGet Gallery. Sometimes they have the same API, however sometimes they do not. For instance, Twilio has a great component that has very specific and tight integration with iOS and Android, and requires you to write code in the platform specific project.

Plugin

When I refer to a plugin for Xamarin, I am referring to a special kind of NuGet that adds cross-platform functionality or abstracts platform specific functionality to a common API. These are both completely cross-platform and extremely small (i.e., they do 1 or 2 things really well with minimal to no dependencies). The plugin API can be accessed on each platform; however, most likely you will only use the common API in a Portable Class Library or Shared Code project.

I like to use the name Plugin as it follows the same pattern as MVVMCross. In fact, nearly every single MVVMCross Plugin could be turned into a Plugin for Xamarin & Windows with a small amount of work so any Xamarin developer could take advantage of it.

I created my Vibrate and Settings Plugins specifically to provide simple examples of Plugins for Xamarin & Windows - but another great source for model plugins would be nearly anything that comes from Paul Betts, such as Akavache.

Xamarin.Forms or Xamarin plugin?

If you read my earlier blog post about creating plugins specifically for Xamarin.Forms, you might be wondering if you should create them for only Xamarin.Forms or if you should create a more platform independent Xamarin plugin. This is a great question as well and just remember that any “Xamarin plugin” would work in a Xamarin.Forms project. So, it really only depends on what you are trying to accomplish. If you intend to leverage some of the functionality that is built into Xamarin.Forms, or to create custom controls for Xamarin.Forms, then your plugin should be a “Plugin for Xamarin.Forms”.

If you are not using anything that explicitly depends on Xamarin.Forms, then you should really strive to make it completely platform independent, and leverage the Bait & Switch approach to target iOS, Android, and Windows Platforms. I tend to always attempt to target iOS, Android, and Windows Phone at minimum in all of my plugins to ensure compatibility with Xamarin.Forms.

Naming

After taking a few swings at this, I’ve found that following this naming scheme works pretty well:

  • Xamarin.Forms only:
  • Feature Plugin for Xamarin.Forms
  • Xamarin.iOS/Android/Mac:
  • Feature Plugin for Xamarin
  • Xamarin + Windows Platforms:
  • Feature Plugin for Xamarin and Windows

Replacing “Feature” with what your plugin does :)

If you want to learn more about creating plugins, be sure to check out my full repo on GitHub.

]]>