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
- Server configures what data to collect (metadata, location)
- Callback receives configuration via
initValuecalls - Client calls
collect()with optional customization - 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
-
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 }
-
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
Declaration
Swift
public override func initValue(name: String, value: Any)Parameters
nameThe name of the property being initialized
valueThe value containing the property configuration
-
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
- Creates DeviceProfileConfig with server settings
- Applies custom configuration via configBlock
- Performs device profile collection
- Serializes results to JSON
- 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
configBlockConfiguration 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
View on GitHub