Link OS SDK for XamarinForm Application

A Alok Pandey 3 years ago
2 1 0

Dear Support,
I want to integrate the LInk OS SDK to my XamarinForms application to provide the Bluetooth printing. I am referring the below sample :_

GitHub - Zebra/LinkOS-Xamarin-Samples: Sample code for developing cross-platform applications on Android and iOS using X…

I am not able to integrate the Link OS SDK Nuget package version (1.2.0)  to my existing XamarinForms application but getting error but when trying to add  Link OS SDK Nuget package version (1.0.59), it's getting added and able to build and run the application.

But when application is searching for the Bluetooth printer and throwing exception to the below highlighted line:-

  public void FindBluetoothPrinters(IDiscoveryHandler handler) {
            const string permission = Manifest.Permission.AccessCoarseLocation;
            if (ContextCompat.CheckSelfPermission(Application.Context, permission) == (int)Permission.Granted) {
             
               BluetoothDiscoverer.Current.FindPrinters(Application.Context, handler);
                return;
            }

            TempHandler = handler;
            // Finally request permissions with the list of permissions and ID
            ActivityCompat.RequestPermissions(MainActivity.GetActivity(), PermissionsLocation, RequestLocationId);
        }

The exception is shown as below :-
{System.InvalidCastException: Specified cast is not valid.
  at LinkOS.Plugin.BluetoothDiscovererImplementation.FindPrinters (System.Object androidContext, LinkOS.Plugin.Abstractions.IDiscoveryHandler handler) [0x0001f] in C:\repos\xamarin-sdk\Link_OS_SDK_for_Xamarin_Portable\LinkOS\LinkOS.Plugin.Android\BluetoothDiscovererImplementation.cs:30
  at DIGIMobile.Droid.PrinterDiscoveryImplementation.FindBluetoothPrinters (LinkOS.Plugin.Abstractions.IDiscoveryHandler handler) [0x00018] in C:\DIGIMOBILE\DIGIMobile-DL\DIGIMobile\LMSMobile.Droid\PrinterDiscoveryImplementation.cs:58
  at DIGIMobile.Views.BluetoothPrinter.SelectPrinterView.StartDiscovery (DIGIMobile.Models.ConnectionType connectionType) [0x0005d] in C:\DIGIMOBILE\DIGIMobile-DL\DIGIMobile\LMSMobile\Views\BluetoothPrinter\SelectPrinterView.cs:138 }

Looking ahead for your quick reply to resolve this issue.
Note:- The sample application is based on the standard project template where as our application is based on PCL template.

Thanks & Regards,
Alok Pandey

Please register or login to post a reply

1 Replies

D Dmitry Prokhorov

Hello Alok,

It looks like an issue and you may need to contact Zebra tech support  with this problem.
Currently your message posted on developers portal and this way tech support may miss it.

Dmitry Prokhorov
Software Engineer, Kutir Mobility
Posted on behalf of Zebra Technologies

CONTACT
Can’t find what you’re looking for?