An object that presents a UI with information about how to use
Tap to Pay on iPhone.
Use a ``ProximityReaderDiscovery`` object to educate people
on how to read contactless credentials with their iPhone.
When building a reader interface in your app, include controls to display help
information. When a person taps those controls, use this type
to present a view controller with information about how to use
a particular feature. The system manages the
presented view controller, displaying materials to teach
people how the system works.
Create a ``ProximityReaderDiscovery`` object in response to requests
for help from your app’s interface. Fetch a relevant help topic
and present that topic using the ``presentContent(_:from:)`` method, as
shown in the following example. Present the topic displays a new
view controller with information about how to use the relevant
features. This view controller remains visible until the person
dismisses it, at which point control returns to your app’s current
view controller.
```
let proximityReaderDiscovery = ProximityReaderDiscovery()
Task {
do {
let content = try await proximityReaderDiscovery.content(for: ProximityReaderDiscovery.Topic.payment(.howToTap))
try await proximityReaderDiscovery.presentContent(content, from: myCurrentViewController)
} catch {
// Handle content display errors.
}
}
```
Members (4)
get · iOS 18.0+
contentList
TypeScript
get contentList(): Promise<Array<ProximityReaderDiscovery_Content>>
Swift declaration
final var contentList: [ProximityReaderDiscovery.Content] { get async throws }
The content you can present for the current device.
This property contains zero or more ``Content`` structures, each
of which corresponds to information on a supported topic. The
content associated with each structure is specific to the country
of the current device. The array can be empty if no content is
available for the current country.
Use this list only when you need to display a topic that isn't
available in ``ProximityReaderDiscovery/Topic``. In all other
cases, use the ``content(for:)`` method to fetch the topic.
Accessing this property fetches the ``Content`` structures from
the system. If the system is unable to fetch the needed information,
it throws an error.
final func presentContent(_ content: ProximityReaderDiscovery.Content, from viewController: UIViewController) async throws
Presents a sheet that teaches merchants how to use the specified
feature.
- Parameters:
- content: The topic to teach. You can get a list of available
topics from the ``contentList`` property or fetch a topic for a
specific subject using the ``content(for:)`` method.
- viewController: The view controller to use when presenting the
sheet. Specify a currently visible view controller in your app.
- Throws: This method throws a ``ContentError`` if the sheet fails to appear.
Call this method when you want to display information about how to use
``ProximityReader`` features on a merchant’s iPhone. For example,
you might use this method to display instructions for how the merchant
uses Tap to Pay on iPhone. This method presents the requested information
in a sheet on top of your app’s UI, which remains on-screen until the
person dismiss it or an error occurs.
final func content(for topic: ProximityReaderDiscovery.Topic) async throws -> ProximityReaderDiscovery.Content
Fetches the content for the specified topic.
- Parameters:
- topic: The topic you want to display.
- Returns: The requested content, when successful.
- Throws: The method throws a ``ContentError`` if it fails to get
the content.
Call this method to get the content definition for the specified topic.
The discovery interface uses the specified identifier to determine
what to display.
init · iOS 18.0+
init
TypeScript
static init(): ProximityReaderDiscovery
Swift declaration
init()
Creates a new proximity reader discovery object.
- Returns: A proximity reader discovery object you can use to
present information to merchants.