Skip to content

Instantly share code, notes, and snippets.

@steveoleary
Last active October 1, 2019 12:49
Show Gist options
  • Save steveoleary/5aa5fd6bff5e40a9328730d10c7ed2a9 to your computer and use it in GitHub Desktop.
Save steveoleary/5aa5fd6bff5e40a9328730d10c7ed2a9 to your computer and use it in GitHub Desktop.
Extension method to convert NSData into string representation
//Use this extension method to get the hex string from NSData, I use this to get the push notification token in iOS >= 13
public static string HexadecimalStringFromData(this NSData data)
{
nuint dataLength = data.Length;
if (dataLength == 0)
{
return null;
}
return string.Join(string.Empty, data.Select(b => b.ToString("X2")).ToList());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment