Thursday, 24 January 2013

Get Mac Computer's Unique Id in Xamarin.Mac

I've been developing and publishing many betting tools for a while and for all of those applications, we had some kind of activation process in which a unique identifier for each computer is generated and based on that we authorize the computer and so forth. For Windows, I used a combination of MAC address with CPU serial number to generate this machine specific unique identifier. For Mac computers, I searched the internet for unique identifier and found many commands which return a supposedly unique identifier, here is a link of one of them.

As I said in my previous post, there is not that much code samples for MonoMac and Xamarin.Mac, but for Objective C, there are good samples. And that's why for a Xamarin.Mac developer it is really required to be familiar with Objective C.

In this post, I'm providing the code translation of the function which was originally written in Objective C (which is taken from the StackOverflow) to get the unique identifier of a Mac computer: