GdprInfo 2.0.0

dotnet add package GdprInfo --version 2.0.0                
NuGet\Install-Package GdprInfo -Version 2.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="GdprInfo" Version="2.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add GdprInfo --version 2.0.0                
#r "nuget: GdprInfo, 2.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.
// Install GdprInfo as a Cake Addin
#addin nuget:?package=GdprInfo&version=2.0.0

// Install GdprInfo as a Cake Tool
#tool nuget:?package=GdprInfo&version=2.0.0                

GdprInfo

A .NET MAUI package for Android and iOS with the main purpose of detecting if the current device is in the EEA, which would make it subject to the GDPR regulation.

Build Status NuGet GitHub Release

Installation

Install via NuGet using:

PM> Install-Package GdprInfo

Usage

Registration

Register the service in your MauiProgram file.

using GdprInfo;

public static class MauiProgram
{
    public static MauiApp CreateMauiApp()
    {
        var builder = MauiApp.CreateBuilder();
        builder
            .UseMauiApp<App>()
            // Other services before...
            .ConfigureGdprInfo()
            // Other service after...
            ;

        return builder.Build();
    }
}

Consumption:

Inject the service via dependency injection in the constructor of the depending class.

private readonly IGdprInfoService _gdprInfoService;

public MyConstructor(IGdprInfoService gdprInfoService)
{
    _gdprInfoService = gdprInfoService;
}

Check if device is in European Economic Area (EEA):

bool result = _gdprInfoService.IsDeviceInEeaOrUnknow;

You can also get the ISO country code of the current device

string? isoCode = _gdprInfoService.IsoCountryCode;

If the ISO code is not null and is part of the EEA, you can also get additional information about the country like this:

string? countryName = _gdprInfoService.CountryName;
string? countryNumber = _gdprInfoService.CountryNumber;
string? longCountryCode = _gdprInfoService.LongCountryCode;

How does it work

The service first tries to get the ISO country code via the device telemetry data i.e. network and SIM provider information. If we can't get it from there we look it up from the device's current local setting. Reasons for why we couldn't receive it from telemetry data could be for example that the device is in Flight Mode or that the device has no SIM card inserted at all.

In case that we couldn't receive the ISO code (unknown), we always have to assume that the device owner is in the EEA. So if the ISO code is unknown, IsDeviceInEeaOrUnknow will return true.

Project State

The project is kind of archived. I do occasional updates as I require them for personal use, but to be honest, in the mean time there are much better ways of doing what this package was trying to do.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-android31.0 is compatible.  net6.0-ios was computed.  net6.0-ios16.1 is compatible.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows 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
2.0.0 410 1/31/2023
1.0.2 305 1/31/2023
1.0.1 452 5/2/2022
1.0.0 1,034 10/6/2019