Scan QR code using Xamarin Forms

Jassim Al Rahma 1,526 Reputation points
2022-01-25T20:50:38.617+00:00

Hi,

How can I scan QR code in Xamarin Forms using the Native iOS and Android and without having to use a thirdparty tool?

Thanks,
Jassim

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,296 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Amy Peng-MSFT 231 Reputation points Microsoft Employee
    2022-01-28T06:53:22.473+00:00

    Hello,

    If you want to scan QR code in Xamarin Forms using the Native API, you can do it by using this way:

    1. First we need to find a Xamarin Wrapper to use native APIs on Android and iOS:
      iOS: you can use this CIDetector.CreateQRDetector to recognizes QR codes. Android: Based on this google doc we can use ML Kit to recognize and decode barcodes in Android Application. In Xamarin ML Kit is wrapped in the Xamarin GooglePlay Services: Xamarin.Google.MLKit.BarcodeScanning. UWP: You can use this BarcodeScanner API directly.

    2. Then you can use DependencyService to enable Xamarin.Forms applications to invoke native platform API.
    For how to use DependencyService, please check:
    https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/dependency-service/introduction.

    Thanks,
    Amy Peng