title: How to make UIDeviceOrientation from automatically becoming portrait when phone is first unlocked?
body: <p>I am currently making a game that in which if you pick up your phone first, then you lose. Therefore, I have an orientation observer that checks when the phone has been picked up (portrait). However, whenever I lock the phone and then unlock it, the orientation observer automatically thinks the phone is in portrait mode even the phone is face up.</p>
  
  <p>I have tried removing the observer and adding it back after a couple of seconds of unlocking the phone.</p>
  
  <pre><code>NotificationCenter.default.addObserver(forName: UIDevice.orientationDidChangeNotification, object: nil, queue: OperationQueue.main, using: { note in
  
              let orientation: UIDeviceOrientation = UIDevice.current.orientation
              if orientation == .faceUp {
                  print("yeoo")
  
              } else if orientation == .portrait {
                  print(1)
                  if (self.gameMode == "game1") {
  
                      if (self.host == Auth.auth().currentUser?.uid) {
                          self.ref.child("games").child(String(self.randNum ?? 0)).child("hostPickUp").setValue("true")
                          let alert = UIAlertController(title: "Phone Picked Up", message: "You picked up your phone and must pay the penalty!", preferredStyle: UIAlertController.Style.alert)
  
                          alert.addAction(UIAlertAction(title: "Yes, I Pay", style: UIAlertAction.Style.default, handler: { _ in
                              self.ref.child("games").child(String(self.randNum ?? 0)).child("recent").setValue(Auth.auth().currentUser?.uid)
                              self.ref.child("games").child(String(self.randNum ?? 0)).child("players").child((Auth.auth().currentUser?.uid)!).child("pickedUpPhone").setValue("true")
                              self.ref.child("games").child(String(self.randNum ?? 0)).child("players").child((Auth.auth().currentUser?.uid)!).child("time").setValue(self.secs)
                          }))
  
                          alert.addAction(UIAlertAction(title: "Call it Even", style: UIAlertAction.Style.default, handler: { _ in
                              self.ref.child("games").child(String(self.randNum ?? 0)).child("callItEven").setValue("true")
                              self.ref.child("games").child(String(self.randNum ?? 0)).child("recent").setValue("calliteven")
                          }))
  
                          self.present(alert, animated: true, completion: nil)
                      } else {
                          self.ref.child("games").child(String(self.randNum ?? 0)).child("recent").setValue(Auth.auth().currentUser?.uid)
                          self.ref.child("games").child(String(self.randNum ?? 0)).child("players").child((Auth.auth().currentUser?.uid)!).child("pickedUpPhone").setValue("true")
                          self.ref.child("games").child(String(self.randNum ?? 0)).child("players").child((Auth.auth().currentUser?.uid)!).child("time").setValue(self.secs)
                      }
  
                  } else if (self.gameMode == "game2"){
  
                      self.timer2.invalidate()
                      self.ref.child("games").child(String(self.randNum ?? 0)).child("players").child((Auth.auth().currentUser?.uid)!).child("pickedUpPhone").setValue("true")
                      self.ref.child("games").child(String(self.randNum ?? 0)).child("players").child((Auth.auth().currentUser?.uid)!).child("time").setValue(self.secs)
                      self.ref.child("games").child(String(self.randNum ?? 0)).child("finalTime").setValue(self.secs)
                      self.ref.child("games").child(String(self.randNum ?? 0)).child("recent").setValue(Auth.auth().currentUser?.uid)
                  }
              }
  </code></pre>