Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anupamchugh/b8b6897ea55622f61bfb58ec74957bcb to your computer and use it in GitHub Desktop.
Save anupamchugh/b8b6897ea55622f61bfb58ec74957bcb to your computer and use it in GitHub Desktop.
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
if let userID = UserDefaults.standard.object(forKey: "userId") as? String {
let appleIDProvider = ASAuthorizationAppleIDProvider()
appleIDProvider.getCredentialState(forUserID: userID) { (state, error) in
DispatchQueue.main.async {
switch state
{
case .authorized: // valid user id
self.settings.authorization = 1
break
case .revoked: // user revoked authorization
self.settings.authorization = -1
break
case .notFound: //not found
self.settings.authorization = 0
break
default:
break
}
}
}
}
let contentView = ContentView()
if let windowScene = scene as? UIWindowScene {
let window = UIWindow(windowScene: windowScene)
window.rootViewController = UIHostingController(rootView: contentView.environmentObject(settings))
self.window = window
window.makeKeyAndVisible()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment