Skip to content

SKAdNetwork

The AffiseSKAdNetwork pod wraps Apple’s StoreKit Ad Network APIs and picks the correct call for the current iOS version. The Swift entry point is @objc public class AffiseSKAd: NSObject (AffiseSKAdNetwork/Classes/AffiseSKAd.swift:10-11).

For the pod coordinates and SPM product, see SKAdNetwork module.

public static func register(_ completionHandler: @escaping (String) -> Void)

Obj-C bridge: @objc(registerWithCompletionHandler:)AffiseSKAdNetwork/Classes/AffiseSKAd.swift:13-33.

On iOS 14.0+ this invokes SKAdNetwork.registerAppForAdNetworkAttribution(). Below iOS 14.0 the completion handler receives a "<OS> <version> Not supported" string (AffiseSKAd.swift:15-33).

import AffiseSKAdNetwork
AffiseSKAd.register { error in
// Handle error
}
public static func updatePostbackConversionValue(
fineValue: Int,
coarseValue: CoarseValue?,
_ completionHandler: @escaping (String) -> Void
)

Obj-C bridge: @objc(updatePostbackWithFineValue:coarseValue:completionHandler:)AffiseSKAdNetwork/Classes/AffiseSKAd.swift:35-57.

Version gates from the implementation (AffiseSKAd.swift:35-57):

  • iOS 16.1+ — forwards fineValue + coarseValue to SKAdNetwork.updatePostbackConversionValue(_:coarseValue:completionHandler:).
  • iOS 15.4+ — forwards fineValue only to SKAdNetwork.updatePostbackConversionValue(_:completionHandler:).
  • iOS 14.0+ — falls back to legacy SKAdNetwork.updateConversionValue(_:).
  • Otherwise the completion handler receives "<OS> <version> Not supported".

“Second argument coarseValue is available in iOS 16.1+”.

AffiseSKAd.updatePostbackConversionValue(fineValue: 1, coarseValue: CoarseConversionValue.medium) { error in
// Handle error
}

Two helper classes wrap Apple’s opaque coarse-value strings:

  • @objc public class CoarseConversionValue: NSObjectAffiseSKAdNetwork/Classes/CoarseConversionValue.swift:4
    • @objc public static let high — line 7
    • @objc public static let low — line 10
    • @objc public static let medium — line 13
    • public static func raw(_ value: String) -> CoarseValue — line 15
  • @objc public class CoarseValue: NSObjectAffiseSKAdNetwork/Classes/CoarseValue.swift:4
    • public init(_ value: String) — line 8

Verbatim:

<key>CFBundleURLTypes</key>
<array>
<dict>
<key>NSAdvertisingAttributionReportEndpoint</key>
<string>https://affise-skadnetwork.com/</string>
</dict>
</array>

A lower-level Obj-C wrapper is available at @interface AffiseStoreKitWrapper : NSObject (AffiseSKAdNetwork/ObjC/AffiseStoreKitWrapper.h:16-24), exposing registerAppForAdNetworkAttribution, updateConversionValue, updatePostbackConversionValue, updatePostbackConversionValue:coarseValue:, and updatePostbackConversionValue:coarseValue:lockWindow:.