Interface INearbyAdvertiser
- Namespace
- Plugin.Maui.NearbyConnectivity
- Assembly
- Plugin.Maui.NearbyConnectivity.dll
Advertising: makes this device visible to nearby discoverers and answers their connection requests.
public interface INearbyAdvertiser : INearbyActivity
- Inherited Members
Methods
SetConsent(NearbyConsentPolicy, Func<NearbyDevice, CancellationToken, ValueTask<bool?>>?)
Sets how inbound connection requests are answered, with an optional per-device rule.
void SetConsent(NearbyConsentPolicy policy, Func<NearbyDevice, CancellationToken, ValueTask<bool?>>? decide = null)
Parameters
policyNearbyConsentPolicyWhat to do when
decidemakes no decision.decideFunc<NearbyDevice, CancellationToken, ValueTask<bool?>>Decides per device: true to accept, false to decline, or null to fall through to
policy. When null itself, every request falls through. Its token is canceled when the request's offer expires or advertising stops.
Examples
nearby.Advertiser.SetConsent(
NearbyConsentPolicy.Hold,
decide: (device, cancellationToken) => PromptAsync(device, cancellationToken));
Remarks
Replaces both the policy and any per-device rule: calling this without
decide clears a rule installed by an earlier call. It applies to requests
received after it returns; one already outstanding stays answerable.
decide returning null hands the decision back, so
a request a rule cannot settle still reaches a person: the device reports
RequestReceived and carries it on
Request.
decide may prompt. It runs on its own thread-pool task per request,
so a slow answer holds only that request. The plugin enforces the offer's deadline: when it
passes, or advertising stops, the token is canceled, the request is declined, and an answer
that arrives later is ignored. A decide that throws is logged and the
request is held. Marshal to the UI thread yourself before showing a prompt.