How to implement the Enterprise Apple SSO: Part Two Check Access Status

In this post I will be talking about how to check the access status using the VideoSubscriberAccount framework.

One of the important things to do when you want to implement AppleSSO is import VideoSubscriberAccount in your project, that framework is already provided by Apple, so you just need to import that framework like this.

import VideoSubscriberAccount

Then you need to create an instance of VSAccountManager.

That object coordinates your app’s authentication requests with a TV provider’s authentication service.

That framework provides a method to knows what is the current status of the VSAccountManager,

open func checkAccessStatus(options: [VSCheckAccessOption : Any] = [:], completionHandler: @escaping (VSAccountAccessStatus, Error?) -> Void)

This method determines the state of the application’s access to the user’s subscription information.

Then we just need to call that method like this:

accountManager.checkAccessStatus(options: [.prompt: true]) { (status, error) in   // Do something here.}

Note: The prompt option will give the opportunity of grant access to AppleSSO subscription.

The first time that you run the application and touch the check access button you will see an alert asking you to about grant access to AppleSSO subscription.

After you select allow the next time you don’t going to see that alert message again.

The next time that you try this method you will see something like this.

As you can see the status now is granted.

What about the TV Providers?

You just need to go to

Settings — TV Provider in your device.

And see the providers that are enabled in your device.

The common mistakes

  • You can get an inconsistency exception like this:
‘NSInternalInconsistencyException’, reason: ‘This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app’s Info.plist must contain an NSVideoSubscriberAccountUsageDescription key with a string value explaining to the user how the app uses this data.’

For solve that exception you need to add the NSVideoSubscriberAccountUsageDescription key to the app’s plist.

<key>NSVideoSubscriberAccountUsageDescription</key><string>Usage description</string>
  • You can get an entitlement error like this:
[Errors] Check access caller process lacks entitlement: Error Domain=VSPrivateErrorDomain Code=-5 “The entitlement is missing.” UserInfo={NSLocalizedDescription=The entitlement is missing.}

For solve that error first check if you already set the Code Signing Entitlements in the build settings section.

If that is correct then maybe you need to check the entitlements path.

That means the entitlements file should be in the root directory.

  • You can get an error related to grant access to AppleSSO.
[Errors] View service failed: Error Domain=VSPrivateErrorDomain Code=-12 “The account access has not yet been determined.” UserInfo={NSLocalizedDescription=The account access has not yet been determined.}

For fix that just don’t forget to add this options: [.prompt: true] to the function call.

Now we are ready for grant access to AppleSSO, see you in the next part.

Additional resources

  • Video Subscriber Account
  • VSAccountManager
  • How to implement the Enterprise Apple SSO: Part One
  • AppleSSO project



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Tony Trejo

Tony Trejo

Experienced Software Engineer with 12+ years of experience.