iOS 15 introduced Focus mode. Apple mentioned that communication apps can query if the device is currently in Focus so we can tell the other person that they might not be notified of messages. However I couldn't find the API in apple docs. Does anyone know?
See https://developer.apple.com/forums/thread/682143
FocusStatusCenter
import Intents
/// Retrieve the current authorization status: INFocusStatusAuthorizationStatus
INFocusStatusCenter.default.authorizationStatus
/// Request authorization to check Focus Status
//
INFocusStatusCenter.default.requestAuthorization { status in
/// Provides a INFocusStatusAuthorizationStatus
}
/// Check if Focus is enabled. INFocusStatusAuthorizationStatus must be .authorized
INFocusStatusCenter.default.focusStatus.isFocused
You need add NSFocusStatusUsageDescription
to Info.plist
https://onesignal.com/blog/ios-notification-changes-updates-from-apples-wwdc-21/