Jc.OpenNov.Avalonia.Android 1.0.0

dotnet add package Jc.OpenNov.Avalonia.Android --version 1.0.0
                    
NuGet\Install-Package Jc.OpenNov.Avalonia.Android -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Jc.OpenNov.Avalonia.Android" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Jc.OpenNov.Avalonia.Android" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Jc.OpenNov.Avalonia.Android" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Jc.OpenNov.Avalonia.Android --version 1.0.0
                    
#r "nuget: Jc.OpenNov.Avalonia.Android, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Jc.OpenNov.Avalonia.Android@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Jc.OpenNov.Avalonia.Android&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Jc.OpenNov.Avalonia.Android&version=1.0.0
                    
Install as a Cake Tool

Jc.OpenNov

Library for reading data from NFC Novo Nordisk insulin pens in .NET.

C# implementation derived from lcacheux's Kotlin nov-open-reader project - big thanks!

Table of Contents

Introduction

Jc.OpenNov is a library designed to facilitate the reading of data from NFC Novo Nordisk insulin pens from iOS and Android in .NET.

Components

  • Jc.OpenNov: Core library containing data structure and protocol implementation.
  • Jc.OpenNov.Nfc.Android: Android implementation of NFC communication using Jc.OpenNov.
  • Jc.OpenNov.Avalonia: Avalonia implementation of NFC communication using Jc.OpenNov.
  • Jc.OpenNov.Avalonia.Android: Android implementation of NFC communication using Jc.OpenNov.Avalonia.
  • Jc.OpenNov.Avalonia.iOS: iOS implementation of NFC communication using Jc.OpenNov.Avalonia.

Sample Screenshots

Android iOS
<img alt="Android" src="img/android.JPG" width="250" /> <img alt="Android" src="img/ios.jpeg" width="250" />

Usage

Barebones (MAUI/etc.)

To use Jc.OpenNov, you need to install the NuGet package:

dotnet add package Jc.OpenNov

Followed by adding the Android/iOS Jc.OpenNov.Nfc.xxx package to your project:

dotnet add package Jc.OpenNov.Nfc.Android

Avalonia Android

Install the following NuGet packages to their respective projects:

dotnet add package Jc.OpenNov.Avalonia
dotnet add package Jc.OpenNov.Avalonia.Android

Add the following to your AndroidManifest.xml:

<uses-permission android:name="android.permission.NFC" />
<uses-feature android:name="android.hardware.nfc" android:required="true" />

In your MainActivity, add to your AppBuilder like so:

protected override AppBuilder CustomizeAppBuilder(AppBuilder builder)
{
    return base.CustomizeAppBuilder(builder)
        // ...
        .UseOpenNov(this);
}

Avalonia iOS

Install the following NuGet packages to their respective projects:

dotnet add package Jc.OpenNov.Avalonia
dotnet add package Jc.OpenNov.Avalonia.iOS

Add the following to your Entitlements.plist:

<key>com.apple.developer.nfc.readersession.formats</key>
<array>
    <string>TAG</string>
</array>

and the following to your Info.plist:

<key>NFCReaderUsageDescription</key>
<string>Used to retrieve data from Novopens.</string>
<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
<array>
    <string>D2760000850101</string>
    <string>E103</string>
    <string>E104</string>
</array>

In your AppDelegate, add to your AppBuilder like so:

protected override AppBuilder CustomizeAppBuilder(AppBuilder builder)
{
    return base.CustomizeAppBuilder(builder)
        // ...
        .UseOpenNov();
}

Avalonia

To start listening for NFC tags, call:

OpenNov.Current.MonitorNfc(/* you may pass in an optional stop condition */);

Likewise, to stop listening for NFC tags, call:

OpenNov.Current.StopNfc();

To know when an NFC tag is detected and data is obtained, subscribe to the event handlers:

public MainViewModel()
{
    StarNfcCommand = ReactiveCommand.Create(StartNfc);
    StopNfcCommand = ReactiveCommand.Create(StopNfc);

    Avalonia.OpenNov.Current.OnDataRead += OnDataRead;
    Avalonia.OpenNov.Current.OnTagDetected += OnTagDetected;
    Avalonia.OpenNov.Current.OnError += OnError;
}

~MainViewModel()
{
    Avalonia.OpenNov.Current.OnDataRead -= OnDataRead;
    Avalonia.OpenNov.Current.OnTagDetected -= OnTagDetected;
    Avalonia.OpenNov.Current.OnError -= OnError;
}

private void OnDataRead(object? sender, Data.PenResult e)
{
    if (e is Data.PenResult.Success success)
    {
        Serial = success.Data.Serial;
    }
}

private void OnTagDetected(object? sender, ITag? e)
{
    var bytes = e?.GetId();
    if (bytes is null)
    {
        TagId = "Tag not found";
        return;
    }

    TagId = Convert.ToHexString(bytes);
}

private void OnError(object? sender, Exception e)
{
    Error = e.Message;
}
Product Compatible and additional computed target framework versions.
.NET net8.0-android34.0 is compatible.  net9.0-android was computed.  net10.0-android was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 484 7/22/2025
0.2.0 484 7/22/2025
0.2.0-preview100 270 7/20/2025