Using AirPlay as an external display for your iPhone or iPad app

Your iPhone (or iPad) app can use AirPlay for an additional display. However, your app cannot initiate the AirPlay connection. The user must start AirPlay from the command center. (You can use AVRoutePickerView to let the user change what device they are using for AirPlay, but this will NOT allow you to initiate AirPlay.) When that happens, iOS will notify your app that a new external display has connected. Inside your app, detecting and adding content to an AirPlay display is exactly the same as reacting to and adding content to an HDMI display that the user has connected with USB-C or Lightning.

The AirPlay button in Command Center that users press to connect an external display with AirPlay.

To reiterate, users must connect AirPlay from outside your app. AVRoutePickerView cannot be used to initiate AirPlay.