liveBook · Manning

Sharing API

As explained in .NET MAUI in Action

A sharing API is a programming interface that invokes an operating system's mechanism for sharing content or data with other applications or services.

A sharing API invokes the operating system’s sharing mechanism, letting users send content or data to a chosen application or service. .NET MAUI exposes a common abstraction across supported platforms, so an app can share without implementing separate integrations for email, SMS, social media, and other targets. section 3.1

Use a sharing API through this application flow:

  • Collect the content to share, such as a message and a URL. section 3.2
  • Request or verify any permissions required to obtain the content; the FindMe! example checks location permission first. section 3.2
  • Create a share request with a subject, title, text, and URI. section 3.2
  • Call the sharing API so the operating system presents eligible target applications for the user to choose. section 3.1

FindMe! location sharing

A user enters a name and clicks Find Me. The app verifies location permission, obtains the current location through the location API, builds a Bing Maps URL from latitude and longitude, and calls Share.RequestAsync with a ShareTextRequest. The operating system then lets the user choose a registered sharing target. section 3.2

Figure 3.5 All supported OSs provide a sharing API. When an app calls that API, the user is presented with a list of apps that have registered as target applications and can choose to share the content being provided by the host application with the target application.

Shows how the operating system lists applications registered as sharing targets after the host app invokes its sharing API. section 3.1

The abstraction supports sharing from an app but not registering that app as a sharing target. Registering a target requires platform-specific code because .NET MAUI does not provide a unified API for it. section 3.1

How .NET MAUI in Action covers it

How deep it goes
Explains the cross-platform abstraction and demonstrates request construction, but defers sharing-target registration.
Examples
Demonstrates FindMe! sharing a named user location through a Bing Maps URL and a ShareTextRequest.
What it assumes
Assumes basic .NET MAUI event handling and UI fields while teaching the sharing workflow through a concrete location example.
What you can do after
Apply it via .NET MAUI to share text and links through a platform’s available target applications.
How it connects
Connects .NET MAUI with operating systems, sharing targets, location APIs, permissions APIs, and event handlers.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of .NET MAUI in Action. The section links point to the parts of the book it draws on.