Class TransferManager

  • All Implemented Interfaces:
    com.scytales.mvalid.sdk.engagement.DeviceEngagementCapable , com.scytales.mvalid.sdk.retrieval.TerminableTransfer , com.scytales.mvalid.sdk.retrieval.Transfer , com.scytales.mvalid.sdk.retrieval.TransferProgressListenable , com.scytales.mvalid.sdk.retrieval.TransferReceiveDependent

    
    public final class TransferManager
     implements Transfer<D>, TransferReceiveDependent, TransferProgressListenable, DeviceEngagementCapable, TerminableTransfer
                        

    A Singleton Transfer implementation which is configured to support all available Transfer implementations (com.example.demo.api.retrieval.device.BLETransfer, com.example.demo.api.retrieval.device.NFCTransfer, com.example.demo.api.retrieval.server.WebAPITransfer)

    For android SDK >= 31

    • android.Manifest.permission.BLUETOOTH_ADVERTISE
    • android.Manifest.permission.BLUETOOTH_SCAN
    • android.Manifest.permission.BLUETOOTH_CONNECT

    For android SDK <31

    • android.Manifest.permission.ACCESS_FINE_LOCATION
    • android.Manifest.permission.ACCESS_COARSE_LOCATION
        public class SomeActivity extends 
    AppCompatActivity
    implements DeviceEngagementCallback, TransferReceiveCallback, TransferProgressListener { private static final String TAG = "SomeActivity"; private static final Config TM_CONFIG = new Config() .setTransferPriority(HANDOVER_QR, TRANSFER_BLE) .setTransferPriority(HANDOVER_NFC, HANDOVER_NFC); private Map<String, Map<String, Map<String, Boolean>>> docRequests = ... private TransferManager transferManager; private SessionManager sessionManager; @Override protected void onCreate(@Nullable
    android.os.Bundle
    savedInstanceState) { super.onCreate(savedInstanceState); try { transferManager = TransferManager.getInstance(this, TRANSFER_MANAGER_CONFIG); transferManager.setTransferReceiveCallback(this); transferManager.setProgressListener(this); transferManager.enableDeviceEngagement(this,this); } catch (SDKException e) { // handle exception } } @Override public void onEngage(@NonNull Received<EngagementReceived> engagementReceived) { engagementReceived.run( failure -> { android.util.Log.e(TAG, failure.toString()); }, success -> { DeviceEngagement deviceEngagement = success.getDeviceEngagement(); Handover handover = success.getHandover(); try { sessionManager = new SessionManager(deviceEngagement, handover); transferManager.forHandover(handover); transferManager.forDeviceEngagement(deviceEngagement); Request request = Request.create(docRequests, sessionManager); transferManager.send(request); } catch (SDKException e) {
    android.util.Log
    .e(TAG, e.getMessage(), e); } }); } @Override public void onProgressEvent(@NonNull TransferProgressEvent event) {
    android.util.Log
    .d(TAG, event.toString()); } @Override public void onReceive(@NonNull Received<TransferReceived> transferReceived) { transferReceived.run( failure -> {
    android.util.Log
    .e(TAG, failure.toString()); }, success -> { success.runForDevice(receivedBytes -> { SessionData sessionData = sessionManager.decryptResponse(receivedBytes); // do stuff with decrypted }); success.runForServer(receivedBytes -> { // do stuff with receivedBytes }); } }
    Config config = new Config()
         TransferManager transferManager = TransferManager.getInstance(context, config);
    

    Configure when device engagement is done through QR to first try device transfer using ble and if it not available then try using webAPI.

    Config config = new Config()
         config.setTransferPriority(HANDOVER_QR, TRANSFER_BLE, TRANSFER_WEB_API);
    

    Configure to use BLE when device engagement is done with QR and use NFC transfer when device engagement is done with NFC.

    Config config = new Config()
         config.setTransferPriority(HANDOVER_QR, TRANSFER_BLE);
         config.setTransferPriority(HANDOVER_NFC, TRANSFER_NFC);
    

    Configure to use only webAPI, for both QR and NFC device engagement.

    Config config = new Config()
         config.setTransferPriority(HANDOVER_QR, TRANSFER_WEB_API);
         config.setTransferPriority(HANDOVER_NFC, TRANSFER_WEB_API);