setPreferredService method

Future<void> setPreferredService(
  1. bool preferred
)

Makes this app the preferred handler while it is in the foreground.

Without it a tap can go to whichever app owns the AID by default, which for payment AIDs is the user's wallet. Pair it with the app's lifecycle: true on resume, false on pause.

Like respond, this reports nothing back: the returned future completes normally whether or not the claim was made. Android can decline it -- for a service it does not consider eligible -- and a call that arrives with no activity attached does nothing either, which from a lifecycle handler normally means the app is no longer on screen. Either way taps keep going wherever they were going, and the only evidence is a warning in logcat under the NfcUtilPlugin tag.

Implementation

Future<void> setPreferredService(bool preferred) => androidApi.hceSetPreferredService(preferred);