ThreatStatus

@objc
public class ThreatStatus : NSObject, InitializationStateProvider

This class provides the status for all threats or specific threat types. It also includes the overall risk level.

Add an observer for threatStatusChangedNotification using NotificationCenter to be alerted of new threats. Check ThreatStatus.threatStatusChangedNotification for the details.

  • The overall level of risk by combining all threat types being evaluated.

    For example, if any detected threat poses a high risk then the overall threat level will also be deemed to be high.

    Declaration

    Swift

    public var overallThreatLevel: Result<ThreatLevel, Error> { get }
  • Returns the details for a specific threat type including the risk level, evaluation time and status.

    Declaration

    Swift

    public func threat(ofType type: ThreatType) throws -> Threat?

    Parameters

    type

    Threat of type to be retrieved.

    Return Value

    • Threat instance of the requested type.
    • nil if the threat type is invalid.
  • Contains all types of threats that are evaluated by the runtime.

    Declaration

    Swift

    public var allThreats: Result<[Threat], Error> { get }
  • A notification that is posted when the threat status changes

    On receiving a notification the userInfo dictionary will include the threat type which is being notified.

    You can register an observer as follows:

    NotificationCenter.default.addObserver(
        self,
        selector: #selector(onThreatStatusUpdate(notification:)),
        name: ThreatStatus.threatStatusChangedNotification,
        object: nil)
    
    @objc func onThreatStatusUpdate(notification: Notification) {
        ...
        // Get the full threat status information for the notified threat type.
        ThreatStatus().threat(ofType: .deviceSecurity)
    }
    

    Declaration

    Swift

    static let threatStatusChangedNotification: Notification.Name