@@ -7,17 +7,24 @@ import UIKit
77import Cocoa
88#endif
99
10+ /// DeepOne provides comprehensive deep linking and deferred deep linking capabilities for iOS and macOS applications.
11+ /// This modern SDK offers attribution tracking, link generation, and seamless user experience management.
1012@objcMembers
1113public class DeepOne : NSObject {
1214
15+ // MARK: - Attribution Parameters
16+ /// Parameter keys for routing and attribution information (Objective-C compatible)
1317 @objc public static let AttributionParameterOriginURL = " origin_url "
1418 @objc public static let AttributionParameterRoutePath = " route_path "
1519 @objc public static let AttributionParameterQueryParameters = " query_params "
1620 @objc public static let AttributionParameterIsFirstSession = " is_first_session "
1721 @objc public static let AttributionParameterAttributionData = " attribution_data "
1822
23+ // MARK: - Error Constants
24+ /// Error domain for DeepOne operations
1925 @objc public static let DeepOneErrorDomain = " DeepOneErrorDomain "
2026
27+ /// Error codes for DeepOne operations
2128 @objc public enum DeepOneErrorCode : Int {
2229 case invalidConfiguration = 1001
2330 case networkError = 1002
@@ -26,20 +33,26 @@ public class DeepOne: NSObject {
2633 case missingCredentials = 1005
2734 }
2835
36+ // MARK: - Type Aliases
37+ /// Handler for processing incoming deep link attribution with type-safe data model
2938 public typealias AttributionHandler = ( _ attributionData: DeepOneAttributionData ? , _ error: NSError ? ) -> Void
3039
40+ // MARK: - Singleton Instance
3141 public static let shared = DeepOne ( )
3242
43+ // MARK: - Properties
3344 private var isDevelopmentMode = false
3445 private var attributionHandler : AttributionHandler ?
3546
47+ /// API credentials for link verification and generation
3648 private var apiKey : String ? {
3749 guard
3850 let keys = Bundle . main. object ( forInfoDictionaryKey: " DeepOne.keys " ) as? [ String : Any ] ,
3951 let key = keys [ isDevelopmentMode ? " test " : " live " ] as? String else { return nil }
4052 return key
4153 }
4254
55+ /// Tracks if this is the first session ever (persists across reinstalls via keychain)
4356 private var isFirstSession : Bool {
4457 didSet {
4558 if !isFirstSession {
@@ -59,19 +72,36 @@ public class DeepOne: NSObject {
5972 }
6073
6174#if canImport(UIKit)
75+ /// Configures the DeepOne SDK with application launch context and attribution handling.
76+ ///
77+ /// - Parameters:
78+ /// - launchOptions: The launch options from the application delegate
79+ /// - developmentMode: Enable development mode for testing. Default is `false`.
80+ /// - attributionHandler: Closure to handle incoming attribution data
6281 public func configure( launchOptions: [ UIApplication . LaunchOptionsKey : Any ] ? ,
6382 developmentMode: Bool = false ,
6483 attributionHandler: AttributionHandler ? ) {
6584 _configure ( developmentMode: developmentMode, attributionHandler: attributionHandler)
6685 }
6786#elseif canImport(Cocoa)
87+ /// Configures the DeepOne SDK with macOS application context and attribution handling.
88+ ///
89+ /// - Parameters:
90+ /// - notification: The application launch notification
91+ /// - developmentMode: Enable development mode for testing. Default is `false`.
92+ /// - attributionHandler: Closure to handle incoming attribution data
6893 public func configure( notification: Notification ,
6994 developmentMode: Bool = false ,
7095 attributionHandler: AttributionHandler ? ) {
7196 _configure ( developmentMode: developmentMode, attributionHandler: attributionHandler)
7297 }
7398#endif
7499
100+ /// Creates a new attributed link with the specified configuration
101+ ///
102+ /// - Parameters:
103+ /// - configuration: Link configuration containing routing and attribution parameters
104+ /// - completion: Completion handler with the generated URL or error
75105 @objc public func createAttributedLink( configuration: DeepOneCreateLinkBuilder , completion: @escaping ( URL ? , NSError ? ) -> Void ) {
76106 guard let parameters = configuration. buildParameters ( ) else {
77107 let error = NSError ( domain: DeepOne . DeepOneErrorDomain,
@@ -110,6 +140,10 @@ public class DeepOne: NSObject {
110140 }
111141 }
112142
143+ /// Processes universal link user activity for attribution
144+ ///
145+ /// - Parameter activity: The NSUserActivity from universal link handling
146+ /// - Returns: Boolean indicating successful attribution processing
113147 @objc ( continueUserActivity: )
114148 @discardableResult public func processUniversalLink( _ activity: NSUserActivity ) -> Bool {
115149 guard
@@ -118,10 +152,15 @@ public class DeepOne: NSObject {
118152 return processAttributionData ( from: url)
119153 }
120154
155+ /// Clears all persisted attribution data (resets first session tracking)
121156 @objc public func clearAttributionData( ) {
122157 DeepOneCoreAPI . deleteKeychainData ( key: " first_session_marker " )
123158 }
124159
160+ /// Processes an incoming URL for attribution tracking
161+ ///
162+ /// - Parameter url: The URL to process for attribution
163+ /// - Returns: Boolean indicating successful processing
125164 @objc @discardableResult
126165 public func trackAttributionURL( _ url: URL ) -> Bool {
127166 return processAttributionData ( from: url)
@@ -181,6 +220,7 @@ public class DeepOne: NSObject {
181220 }
182221 }
183222
223+ /// Extracts marketing attribution parameters from query parameters
184224 private func extractMarketingAttribution( from queryParams: [ String : Any ] ) -> [ String : Any ] {
185225 var marketingData = [ String: Any] ( )
186226
@@ -205,9 +245,12 @@ public class DeepOne: NSObject {
205245 }
206246}
207247
248+ // MARK: - Swift Convenience Methods
249+
208250#if swift(>=5.5)
209251extension DeepOne {
210252
253+ /// Swift-specific link creation with Result type and async/await
211254 @available ( iOS 13 . 0 , macOS 10 . 15 , * )
212255 public func createAttributedLink( configuration: DeepOneCreateLinkBuilder ) async -> Result < URL , DeepOneSwiftError > {
213256 return await withCheckedContinuation { continuation in
@@ -224,6 +267,7 @@ extension DeepOne {
224267 }
225268}
226269
270+ /// Swift-specific error enum for modern error handling
227271public enum DeepOneSwiftError : Error , LocalizedError {
228272 case invalidConfiguration
229273 case networkError( Error )
0 commit comments