getDeviceAttributes
Gets properties stored about the device that are used in audience filters.
This method returns all device attributes that can be used in audience filters in the Superwall dashboard.
Purpose
Retrieves a dictionary of device properties that are used when evaluating audience filters. This is useful for debugging audience filter behavior or understanding what device attributes are available.
Signature
public func getDeviceAttributes() async -> [String: Any]Parameters
No parameters.
Returns / State
Returns a dictionary mapping attribute names to their values. Common attributes include:
isApplePayAvailable- Whether Apple Pay is available and the user has added a card (available in version 4.9.0+)swiftVersion- The Swift version (available in version 4.7.0+)compilerVersion- The compiler version (available in version 4.7.0+)localeIdentifier- The device localeosVersion- The iOS versionmodel- The device model- And many more device-specific attributes
Usage
Get device attributes:
let deviceAttributes = await Superwall.shared.getDeviceAttributes()
// Check specific attributes
if let isApplePayAvailable = deviceAttributes["isApplePayAvailable"] as? Bool {
print("Apple Pay available: \(isApplePayAvailable)")
}
// Print all attributes for debugging
print("Device attributes: \(deviceAttributes)")Use in audience filter debugging:
Task {
let attributes = await Superwall.shared.getDeviceAttributes()
// Check if user matches an audience filter condition
if let swiftVersion = attributes["swiftVersion"] as? String {
print("Swift version: \(swiftVersion)")
}
}Related
- Device attributes are automatically used in audience filters
isApplePayAvailablewas added in version 4.9.0 and updated in 4.10.5 for more accurate filteringswiftVersionandcompilerVersionwere added in version 4.7.0
How is this guide?
Edit on GitHub