Skip to content

Commit

Permalink
Merge pull request #28 from jfversluis/update-readme
Browse files Browse the repository at this point in the history
Update README.md
  • Loading branch information
Redth authored Aug 30, 2022
2 parents 0fcace0 + 36b110d commit 71a6ea2
Showing 1 changed file with 58 additions and 3 deletions.
61 changes: 58 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,66 @@

# ZXing.Net.MAUI
The successor to ZXing.Net.Mobile

![zxing net maui](https://user-images.githubusercontent.com/271950/129272315-b3f5a468-c585-49f2-bbab-68a884618b94.png)
The successor to ZXing.Net.Mobile: barcode scanning and generation for .NET MAUI applications

<img src="https://user-images.githubusercontent.com/271950/129272315-b3f5a468-c585-49f2-bbab-68a884618b94.png" width="300" />

## Barcode Scanning

### Install ZXing.Net.MAUI

1. Install [ZXing.Net.MAUI](https://www.nuget.org/packages/ZXing.Net.Maui) NuGet package on your .NET MAUI application

1. Make sure to initialize the plugin first in your `MauiProgram.cs`, see below

```csharp
// Add the using to the top
using ZXing.Net.Maui;

// ... other code
public static MauiApp Create()
{
var builder = MauiApp.CreateBuilder();

builder
.UseMauiApp<App>()
.UseBarcodeReader(); // Make sure to add this line
return builder.Build();
}
```

Now we just need to add the right permissions to our app metadata. Find below how to do that for each platform.

#### Android

For Android go to your `AndroidManifest.xml` file (under the Platforms\Android folder) and add the following permissions inside of the `manifest` node:

```xml
<uses-permission android:name="android.permission.CAMERA" />
```

#### iOS

For iOS go to your `info.plist` file (under the Platforms\iOS folder) and add the following permissions inside of the `dict` node:

```xml
<key>NSCameraUsageDescription</key>
<string>This app uses barcode scanning to...</string>
```

Make sure that you enter a clear and valid reason for your app to access the camera. This description will be shown to the user.

#### Windows

Windows is not supported at this time for barcode scanning. You can however use the barcode generation. No extra permissions are required for that.

For more information on permissions, see the [Microsoft Docs](https://docs.microsoft.com/dotnet/maui/platform-integration/appmodel/permissions).
### Using ZXing.Net.Maui

If you're using the controls from XAML, make sure to add the right XML namespace in the root of your file, e.g: `xmlns:zxing="clr-namespace:ZXing.Net.Maui.Controls;assembly=ZXing.Net.MAUI"`

```xaml
<zxing:CameraBarcodeReaderView
x:Name="cameraBarcodeReaderView"
Expand Down

0 comments on commit 71a6ea2

Please sign in to comment.