1. Installation for Xamarin Forms - JimmyPun610/BarcodeScanner.Mobile GitHub Wiki

- Install package from nuget

  1. Install Nuget package to Forms, Android and iOS project
Install-Package BarcodeScanner.Mobile.XamarinForms

- Android setup

  1. Set target framework to MonoAndroid 12

  2. Manifest.xml

<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-permission android:name="android.permission.CAMERA" />

<application ...............>
........

<!-- In case you need the features of Scan from Image, add below provider-->
<provider android:name="androidx.core.content.FileProvider" android:authorities="{your_app_id}.fileprovider" android:exported="false" android:grantUriPermissions="true">
	<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"></meta-data>
</provider>

........
</application>
<!-- In case you need the features of Scan from Image, add below permissions -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

......
......
......
</manifest>
  1. Init the library in MainActivity.cs
  base.OnCreate(savedInstanceState);
//...
  // Init Renederer for BarcodeScanner
  BarcodeScanner.Mobile.XamarinForms.Droid.RendererInitializer.Init();
//...
  global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
  LoadApplication(new App());
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
{
    Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
    base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}
  1. In case you need the features of Scan from Image, add file_paths.xml with Build Action "AndroidResource" to Resources\xml (You may create "xml" folder if it is not exist)
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
	<external-files-path name="my_images" path="Pictures" />
	<external-files-path name="my_movies" path="Movies" />
</paths>

- iOS Setup

  1. Edit Info.plist, add camera rights
	<key>NSCameraUsageDescription</key>
	<string>Require to use camera</string>
	<!-- In case you need the features of Scan from Image, add below permissions -->
	<key>NSPhotoLibraryUsageDescription</key>
	<string>This app needs access to photos.</string>
	<key>NSPhotoLibraryAddUsageDescription</key>
	<string>This app needs access to the photo gallery.</string>
  1. Init project and firebase on AppDelegate.cs
            global::Xamarin.Forms.Forms.Init();
            LoadApplication(new App());
            //....
            BarcodeScanner.Mobile.XamarinForms.iOS.Initializer.Init();
            //....
            return base.FinishedLaunching(app, options);
  1. Set Linker Behavior to Link SDK assemblies only
⚠️ **GitHub.com Fallback** ⚠️