Created
November 13, 2019 17:42
-
-
Save anupamchugh/b8b6897ea55622f61bfb58ec74957bcb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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