DeviceInfo Swift is a lightweight iOS utility that provides essential device data collection required for Singular Server-to-Server (S2S) REST API integration. The project consists of two main components that work together to gather crucial device information for maintaining device graphs and processing out-of-app events.
TL;DR:
- Swift utility classes for collecting iOS device data required for Singular S2S integration
- Captures essential identifiers like IDFA, IDFV, and ATT status
- Provides device information including model, OS version, and build details
- Designed for maintaining device graphs and processing out-of-app events
DeviceIdentifiers Class
class DeviceIdentifiers {
static let shared = DeviceIdentifiers()
var attStatus: String
var idfa: String
var idfv: String
func requestTrackingAuthorization(completion: @escaping (String) -> Void)
func getAllIdentifiers() -> [String: String]
}DeviceInfo Class
class DeviceInfo {
static let shared = DeviceInfo()
var appVersion: String
var bundleID: String
var osVersion: String
var locale: String
var deviceModel: String
var buildVersion: String
func getAllDeviceInfo() -> [String: String]
}Device Identifiers
attStatus: App Tracking Transparency status (iOS 14+)idfa: Advertising identifier for user trackingidfv: Vendor identifier as fallback identifier
Device Information
appVersion: Current app version from bundlebundleID: Application bundle identifierosVersion: Current iOS versionlocale: Device's current locale settingdeviceModel: Physical device model informationbuildVersion: System build version using sysctlbyname
- Initialize the components:
let deviceInfo = DeviceInfo.shared
let deviceIdentifiers = DeviceIdentifiers.shared- Collect device information:
let deviceData = deviceInfo.getAllDeviceInfo()
let identifierData = deviceIdentifiers.getAllIdentifiers()- Request ATT authorization when needed:
deviceIdentifiers.requestTrackingAuthorization { status in
// Handle ATT status
}Store collected data points in your device graph with these key considerations:
- Map multiple identifiers to a single user profile
- Update data points periodically to maintain accuracy
- Handle missing or null values gracefully
When sending events to Singular's REST API:
- Retrieve stored device information from your device graph
- Include relevant device data in the API payload
- Ensure consistent identifier usage across events
- iOS 14.0+
- Swift 5.0+
- Xcode 13.0+
- Required frameworks:
- AdSupport.framework
- AppTrackingTransparency.framework
- UIKit.framework
- Store collected information server-side for consistent tracking
- Update device information periodically to maintain accuracy
- Handle ATT status changes appropriately
- Implement proper error handling for missing data points
- Use the data points when sending event requests to Singular's API
The app provides two ways to verify collected data:
- Xcode console output through printDeviceInfo()
- Visual representation in the DeviceInfoView
| About the App | DeviceInfo Dictionary |
|---|---|
![]() |
![]() |

