Apple TV apps are notoriously difficult to authenticate, requiring developers to go through a lengthy process of signing their app with the tvOS developer portal. This library makes that process easy by providing an API for iOS developers to use in their apps.
The sign in with apple php example is a simple library that allows tvOS apps to authenticate via their iOS counterparts.
The new Apple TV is fantastic, but the keyboard input might be better. You can utilize Voucher to allow your customers login into the TV app using your iOS app instead of having them enter credentials into their TV.
What Is the Process?
Voucher makes use of Bonjour, a tool that allows you to learn about other devices on your network and what they can accomplish. When enabled, Voucher on tvOS looks for any Voucher Server on iOS on your local network and through AWDL (Apple Wireless Direct Link).
When it locates a Voucher Server, it requests authentication. Here’s a link to the demo app:
The example iOS app may then provide a notice to the user (with or without a user interface):
If the user agrees, the iOS app will be able to transmit certain authentication data to the tvOS app (in this case, an auth token string)
Carthage and CocoaPods both have vouchers available. If you want, you may also manually install it.
- Install the repo on your PC by cloning it.
- Only the source files from the Voucher subdirectory should be copied to your project.
Utilizing a Voucher
When a user wishes to authenticate in your tvOS app, you should build a VoucherClient instance and start it:
tvOS is a television operating system (Requesting Auth)
When a user presses the “Login” button, your app should provide some UI telling them to open their iOS app to complete signing in, then launch the voucher client, as seen below:
start import Voucher func Let uniqueId = “SomethingUnique” in VoucherClient(); self.voucher = VoucherClient (uniqueSharedId: uniqueId) self.voucher.startSearchingWithCompletion [unknown self] / (authData is of type NSData) if authData!= nil if authData!= nil if authData!= nil if authData!= nil if authData!= nil if authData!= nil if authData!= nil if otherwise self.authenticationFailed() if self.authenticationSucceeded(authData!, from: displayName)
Apple’s mobile operating system (Providing Auth)
If your iOS app has authentication credentials, it should launch a Voucher Server so that it can respond to any login requests. When (and if) the user is logged in, I’d suggest running the server.
alertController.addAction(UIAlertAction(title: “Allow Auth?”), message: “Allow “(displayName)” access to your login?”, preferredStyle:.Alert) alertController.addAction(UIAlertAction(title: “Not Now”, style:.Cancel, handler: action in responseHandler(nil, nil)) alertController.addAction(UIAlertAction(title:
UIAlertAction(title: “Allow”, style: ), alertController.addAction(UIAlertAction(title: “Allow”, style: ), alertController.addAction(UIAlertAction Default, handler: let authData = “THIS IS AN AUTH TOKEN” action in let authData = “THIS IS AN AUTH TOKEN” responseHandler(authData, nil)! dataUsingEncoding(NSUTF8StringEncoding)!
self.presentViewController is a class that represents a view controller (alertController, animated: true, completion: nil)
Voucher func import start let uniqueId = “SomethingUnique” self VoucherServer() VoucherServer = server (uniqueSharedId: uniqueId) self. (displayName, responseHandler) -> server.startAdvertisingWithRequestHandler alertController.addAction(UIAlertAction(title: “Allow Auth?”), message: “Allow “(displayName)” access to your login?”, preferredStyle:.Alert) alertController.addAction(UIAlertAction(title: “Not Now”, style:.Cancel, handler: action in responseHandler(nil, nil) )) alertController.addAction(UIAlertA dataUsingEncoding(NSUTF8StringEncoding)! responseHandler(authData, nil) )) self.presentViewController(alertController, animated: true, completion: nil) )) self.presentViewController(alertController, animated: true, completion: nil) )) self.presentViewController(alertController, animated: true, completion: nil) ))
Instead of using passwords, use tokens.
While you are free to transmit any data you want to tvOS, you should submit an OAuth token or, better yet, create a single-use token on your server and send that. For example, Cluster utilizes single-use tokens for auto-login from the web to the iOS app. Take a look at my Medium article to see how I do it! For iOS to tvOS logins, the same approach may be used.
The voucher can’t be the sole way to log in.
According to the App Store Submission Guidelines, you must still display the manual input UI on your login screen (Section 2.27). Add message stating that, in addition to the on-screen form, the user may connect by simply opening the iOS app.
Todo / Things I’d Appreciate Your Assistance With!
Encryption? Because Voucher currently does not encrypt any data between the server and the client, I assume that if someone desired your credentials (see the Recommendations section above), they might use a packet sniffer on your local network to get them.
Make Voucher Server compatible with OS X and tvOS! New framework targets and extra test applications are probably all that’s required.
Take a look at Benny Wong’s article on why Apple TV sign-in is a pain. He also has a tvOS Authing demo project that you should look at!
- Versions of iOS 7.0 and above
- tvOS 9.0
- Xcode 8
The MIT license is used to make Voucher accessible. For additional information, see the LICENSE file.
If You’re Using a Voucher, Please Let Me Know!
Contribute to this Github “issue” I created to keep track of who’s utilizing Voucher.
The how to enable sign in with apple is a new library that makes it easy for tvOS apps to authenticate using their iOS counterparts.
- sign in with apple capability not showing
- test sign in with apple simulator
- sign in with apple unique id
- swift authentication tutorial
- asauthorizationappleidbutton ios 12