Matching On Screen Codes to Authorise Access

I have seen apps that have an on-screen prompt on 1 device, like 4 or 6 digits, that is entered on the second. Is this a built-in API, or is it entirely custom written? Specifically used to connect another device, running either the same app or some helper / remote control app.


In my use case, I intend to run an app on multiple devices that can connect to each other and share the app's data. One direction of access will be from an AppleTV to an iOS device (phone or pad). I would like the user's phone to enter in this code.


Can anyone provide pointers, examples or other material so i can learn more, please?


Thanks