title: How to sign in with apple logout
body: <p>When using Apple login, I want to know how to log out. Two revoking methods I know</p>
  
  <p>[1] Upon opening your app</p>
  
  <ol>
  <li>Open the Settings app, then tap [your name].</li>
  <li>Tap Password &amp; Security</li>
  <li>Tap Apps Using Your Apple ID.</li>
  </ol>
  
  <pre><code>let authorizationAppleIDProvider = ASAuthorizationAppleIDProvider()
  
    authorizationAppleIDProvider.getCredentialState(forUserID: "currentUserIdentifier") { (credentialState: ASAuthorizationAppleIDProvider.CredentialState, error: Error?) in
      if let error = error {
        print(error)
        // Something went wrong check error state
        return
      }
      switch (credentialState) {
      case .authorized:
        //User is authorized to continue using your app
        break
      case .revoked:
        //User has revoked access to your app
        break
      case .notFound:
        //User is not found, meaning that the user never signed in through Apple ID
        break
      default: break
      }
    }
  </code></pre>
  
  <p>How to know through this code when running the app afterwards</p>
  
  <p>[2] While your app is running</p>
  
  <pre><code>let notificationCenter = NotificationCenter.default
    let sessionNotificationName = NSNotification.Name.ASAuthorizationAppleIDProviderCredentialRevoked
  
    appleIDSessionObserver = notificationCenter.addObserver(forName: sessionNotificationName, object: nil, queue: nil) { (notification: Notification) in
      //Sign user out
    }
  </code></pre>
  
  <p>This code notifies when a credentialState becomes revoked when a user session changes.</p>
  
  <p>What I'm curious about is [2] While your app is running, in what situation is the user session revoked in the app? For example, if you press the logout button, credentialState becomes revoked, you will receive notifications and execute the logout function, right? How to revoked appleId CredentialState in the context of using the app?</p>