Xamarin integration for Android

If you’re using Xamarin to generate your apps, you must complete the following preparatory steps before you integrate with the Android Mobile SDK.

  1. Generate an AffiniPay Mobile SDK DLL file.
  2. Incorporate the DLL file into your project.

1: Generate an AffiniPay Mobile SDK DLL file

If you have an AffiniPay Mobile SDK DLL file, skip this section.

  1. Create a Android Bindings Project.
  2. Add the AAR file to your Jars directory.
  3. Add the following lines to your Metadata.xml file:
     <remove-node path="/api/package[@name='com.bbpos.bbdevice']/class[@name='BBDeviceController']/method[@name='A']"/>
     <remove-node path="/api/package[@name='com.bbpos.bbdevice']/class[@name='BBDeviceController']/method[@name='B']"/>
     <remove-node path="/api/package[@name='com.bbpos.bbdevice']/class[@name='BBDeviceController']/method[@name='C']"/>
     <remove-node path="/api/package[@name='com.bbpos.bbdevice']/class[@name='BBDeviceController']/method[@name='D']"/>
     <remove-node path="/api/package[@name='com.bbpos.bbdevice']/class[@name='BBDeviceController']/method[@name='E']"/>
     <remove-node path="/api/package[@name='com.bbpos.bbdevice']/class[@name='BBDeviceController']/method[@name='F']"/>
     <remove-node path="/api/package[@name='com.bbpos.bbdevice']/class[@name='BBDeviceController']/method[@name='G']"/>
     <remove-node path="/api/package[@name='com.bbpos.bbdevice']/class[@name='BBDeviceController']/method[@name='H']"/>
     <remove-node path="/api/package[@name='com.bbpos.bbdevice']/class[@name='BBDeviceController']/method[@name='I']"/>
     <remove-node path="/api/package[@name='com.bbpos.bbdevice']/class[@name='BBDeviceController']/method[@name='J']"/>
     <remove-node path="/api/package[@name='com.bbpos.bbdevice']/class[@name='BBDeviceController']/method[@name='K']"/>
     <remove-node path="/api/package[@name='com.bbpos.bbdevice']/class[@name='BBDeviceController']/method[@name='L']"/>
     <remove-node path="/api/package[@name='com.bbpos.bbdevice']/class[@name='BBDeviceController']/method[@name='M']"/>
     <remove-node path="/api/package[@name='com.bbpos.bbdevice']/class[@name='BBDeviceController']/method[@name='N']"/>
     <remove-node path="/api/package[@name='com.bbpos.bbdevice']/class[@name='BBDeviceController']/method[@name='O']"/>
     <remove-node path="/api/package[@name='com.bbpos.bbdevice']/class[@name='BBDeviceController']/method[@name='P']"/>
     <remove-node path="/api/package[@name='com.bbpos.bbdevice']/class[@name='BBDeviceController']/method[@name='Q']"/>
     <remove-node path="/api/package[@name='com.bbpos.bbdevice']/class[@name='BBDeviceController']/method[@name='R']"/>
     <remove-node path="/api/package[@name='com.bbpos.bbdevice']/class[@name='BBDeviceController']/method[@name='S']"/>
     <remove-node path="/api/package[@name='com.bbpos.bbdevice']/class[@name='BBDeviceController']/method[@name='T']"/>
     <remove-node path="/api/package[@name='com.bbpos.bbdevice']/class[@name='BBDeviceController']/method[@name='U']"/>
     <remove-node path="/api/package[@name='com.bbpos.bbdevice']/class[@name='BBDeviceController']/method[@name='V']"/>
     <remove-node path="/api/package[@name='com.bbpos.bbdevice']/class[@name='BBDeviceController']/method[@name='W']"/>
     <remove-node path="/api/package[@name='com.bbpos.bbdevice']/class[@name='BBDeviceController']/method[@name='X']"/>
     <remove-node path="/api/package[@name='com.bbpos.bbdevice']/class[@name='BBDeviceController']/method[@name='Y']"/>
     <remove-node path="/api/package[@name='com.bbpos.bbdevice']/class[@name='BBDeviceController']/method[@name='Z']"/>
     <remove-node path="/api/package[@name='com.affinipay.cardreadersdk.customerinfo']/class[@name='CustomerInfo.CREATOR']"/>

  4. Build the project to generate the DLL file.

2: Incorporate the DLL file into your project

  1. Add the AffiniPay Mobile SDK DLL file to the References in your main app project.
  2. Add the following packages from NuGet:
    • Kotlin StdLib JRE7 (Xamarin.Kotlin.StdLib.JRE7)
    • Google Support Design Library (Xamarin.Android.Support.Design)
    • v7 Appcompat (Xamarin.Android.Support.v7.AppCompat)
    • v4 Support Library (Xamarin.Android.Support.v4)
    • Constraint Layout Library (Xamarin.Android.Support.Constraint.Layout)
    • OkHttp3 Logging interceptor (Naxam.Squareup.OkHttp3.LoggingInterceptor)
    • Retrofit2 (Square.Retrofit2)
    • Retrofit2 GsonConverter (Naxam.Retrofit2.ConvertGson.Droid)
    • RxAndroid (Naxam.RxAndroid.Droid)
    • RxJava2 (Naxam.RxJava2.Droid)
  3. Build a DLL for RxJava2 CallAdapterFactory from the JAR, since no bindings library is available from NuGet. The JAR is available from: https://github.com/square/retrofit/tree/master/retrofit-adapters/rxjava2.

Now you can integrate with Android.