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.
Register
Section titled “Register”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}#import <AffiseSKAdNetwork/AffiseSKAdNetwork-Swift.h>
[AffiseSKAd registerWithCompletionHandler:^(NSString * error) { // Handle error}];Update postback conversion value
Section titled “Update postback conversion value”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+coarseValuetoSKAdNetwork.updatePostbackConversionValue(_:coarseValue:completionHandler:). - iOS 15.4+ — forwards
fineValueonly toSKAdNetwork.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}#import <AffiseSKAdNetwork/AffiseSKAdNetwork-Swift.h>
[AffiseSKAd updatePostbackWithFineValue:1 coarseValue:[CoarseConversionValue medium] completionHandler:^(NSString * error) { // Handle error}];CoarseValue
Section titled “CoarseValue”Two helper classes wrap Apple’s opaque coarse-value strings:
@objc public class CoarseConversionValue: NSObject—AffiseSKAdNetwork/Classes/CoarseConversionValue.swift:4@objc public static let high— line 7@objc public static let low— line 10@objc public static let medium— line 13public static func raw(_ value: String) -> CoarseValue— line 15
@objc public class CoarseValue: NSObject—AffiseSKAdNetwork/Classes/CoarseValue.swift:4public init(_ value: String)— line 8
Postback endpoint in Info.plist
Section titled “Postback endpoint in Info.plist”Verbatim:
<key>CFBundleURLTypes</key><array> <dict> <key>NSAdvertisingAttributionReportEndpoint</key> <string>https://affise-skadnetwork.com/</string> </dict></array>Obj-C wrapper
Section titled “Obj-C wrapper”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:.