DeviceProfileCallback

public class DeviceProfileCallback : AbstractCallback, ObservableObject, @unchecked Sendable

A callback implementation for collecting and processing device profile information.

This callback is used within the Ping Identity journey framework to gather device metadata and location information based on server configuration. It extends AbstractCallback for modern Swift callback handling and provides a streamlined interface for device profiling.

Usage in Journey Flow

  1. Server configures what data to collect (metadata, location)
  2. Callback receives configuration via initValue calls
  3. Client calls collect() with optional customization
  4. Device profile data is submitted back to server

Privacy Considerations

  • Location collection requires user permission
  • Metadata collection is configurable per server policy
  • All data collection respects system privacy settings

Configuration Properties

  • Indicates whether metadata collection is enabled for this callback. This value is set during initialization based on server configuration.

    When enabled, the callback will collect comprehensive device information including platform details, hardware specs, network status, etc.

    Declaration

    Swift

    private(set) public var metadata: Bool { get }
  • Indicates whether location collection is enabled for this callback. This value is set during initialization based on server configuration.

    When enabled, the callback will attempt to collect device location coordinates, subject to user permissions and privacy settings.

    Declaration

    Swift

    private(set) public var location: Bool { get }
  • A message from the server, typically containing instructions or information about the device profile collection process.

    This message can provide context about why device profiling is being requested or instructions for the user about the collection process.

    Declaration

    Swift

    private(set) public var message: String { get }

Initialization

  • Initializes callback properties based on server-provided configuration.

    This method is called automatically during callback initialization to set up the callback based on the server’s requirements for device profiling.

    Supported Properties

    • metadata: Boolean indicating whether to collect device metadata
    • location: Boolean indicating whether to collect location information
    • message: String containing server instructions or context

    Declaration

    Swift

    public override func initValue(name: String, value: Any)

    Parameters

    name

    The name of the property being initialized

    value

    The value containing the property configuration

Collection Methods

  • collect(configBlock:) Asynchronous

    Collects device profile information and submits it to the server.

    This method orchestrates the complete device profile collection process, allowing for custom configuration of collectors and handling all aspects of data gathering and submission.

    Collection Process

    1. Creates DeviceProfileConfig with server settings
    2. Applies custom configuration via configBlock
    3. Performs device profile collection
    4. Serializes results to JSON
    5. Submits data to server via input() call

    Configuration Example

    let result = await callback.collect { config in
        config.collectors {
            return [
                PlatformCollector(),
                CustomCollector()
            ]
        }
    }
    

    Error Handling

    • Automatically submits successful results to server

    Declaration

    Swift

    public func collect(
        configBlock: @escaping @Sendable (DeviceProfileConfig) -> Void = {_ in }
    ) async -> Result<[String: any Sendable], Error>

    Parameters

    configBlock

    Configuration block for customizing device profile collection

    Return Value

    Result containing the collected device profile or an error

  • Returns the payload for the callback submission.

    Declaration

    Swift

    public override func payload() -> [String : Any]

    Return Value

    JSON dictionary for server submission