Skip to content

Instantly share code, notes, and snippets.

@myrickchow32
Last active January 21, 2021 16:05
Show Gist options
  • Save myrickchow32/08131d2c6a77eb9aff61291b1b142e59 to your computer and use it in GitHub Desktop.
Save myrickchow32/08131d2c6a77eb9aff61291b1b142e59 to your computer and use it in GitHub Desktop.
@objc func proximityStateDidChange(notification: Notification) {
if let device = notification.object as? UIDevice {
let currentProximityState = device.proximityState
// true: user is close to the device; false: vice versa
print("currentProximityState: \(currentProximityState ? "near" : "far")")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment