Plugin For Xamarin - James Montemagno https://staging.montemagno.com/tag/plugin-for-xamarin/ https://staging.montemagno.com/content/images/2017/08/MonogramIcon_Orange_NoBuffer.png Plugin For Xamarin - James Montemagno https://staging.montemagno.com/tag/plugin-for-xamarin/ Hugo -- gohugo.io Tue, 13 Oct 2026 23:21:57 GMT 60 Cross-Platform In-App Purchases for Xamarin.Mac Apps! https://staging.montemagno.com/cross-platform-in-app-purchases-for-xamarin-mac-apps/ 6022c9a56c48dd0039592ea7 Tue, 09 Feb 2021 18:04:20 GMT

This week, one of my best friends Frank Krueger released his brilliant app iCircuit 3D for macOS (he also wrote an awesome blog on how it was made). While I know that catalyst support for Xamarin (and .NET MAUI) is coming soon, I still think there are great opportunities to monetize macOS apps written in C# today (see iCircuit 3D!). I released my In-App Billing Plugin a few years ago for iOS, Android, and UWP apps and it has been awesome to hear how it has helped so many developers monetize their apps. The library has expanded over the years to support subscriptions and updated to the latest Android billing libraries. I have used this library personally to monetize my apps including Island Tracker and My Cadence. If you haven't seen the API it is absolutely lovely! Check this out:

Get Product Info

Everything is basically three lines of code... Connect, Call, Disconnect:

var connected = await CrossInAppBilling.Current.ConnectAsync();
if(!connected)
    return;

var items = await CrossInAppBilling.Current.GetProductInfoAsync(ItemType.InAppPurchase, "myitem");

await CrossInAppBilling.Current.DisconnectAsync();

Purchase an Item

Rinse and repeat!

var connected = await CrossInAppBilling.Current.ConnectAsync();
if(!connected)
    return;

var purchase = await CrossInAppBilling.Current.PurchaseAsync(productId, ItemType.InAppPurchase);
if(purchase != null & purcxhase.State == PurchaseState.Purchased)
{
	//item bought
}

await CrossInAppBilling.Current.DisconnectAsync();

Now for Xamarin.Mac!

I recently had a few user of My Stream Timer as me how they can donate and support the development of the app. I never really thought about monetizing the app as I made it sort of for myself to show a countdown before my streams. However, this app has grown to nearly 20,000 downloads from all sorts of streamers including yoga instructors, teachers, coders, and gamers! So I figure I would extend support for my plugin to macOS. This weekend I sat down and 3 hours later it was done! Luckily for me the API is extremely similar to iOS with StoreKit. There are a few differences around making the actual purchase where you can't specify a string id, but instead must get the actual product from StoreKit first. Luckily this method already existed in my code and after a bit of hacking I got it working. Oh and there is no TransactionReceipt, which is weird but there are newer APIs that developers are supposed to query. Beyond that the API works as expected! Check it out!

In app purchase in My Stream Timer

My favorite part has to be testing IAPs on macOS because it is so simple. All you need to do is log out of the app store and then open your app in debug and make the purchase! It just works! I love it!

If you are making macOS apps I hope that you will checkout the plugin and try to add some monetization to your app!

]]>
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!

]]>