Version: 1.0.4
Organization: Thủ Đô Multimedia
This document provides a guide for integrating and using the SSAITracking SDK for iOS applications, specifically for iOS version 12.4 and above. It includes detailed information on installation, SDK initialization, and handling necessary callbacks.
This document applies to iOS developers who want to integrate the SSAITracking SDK into their applications, including requesting IDFA access as per App Tracking Transparency requirements.
- Operating System: iOS 12.4 and above
- Device: Physical device required
- Additional Requirement: App Tracking Transparency authorization needed on ios 14+
To install the SSAITracking SDK, follow these steps:
- Update Info.plist:
- Add the
NSUserTrackingUsageDescription
key with a custom message describing the usage of IDFA:
<key>NSUserTrackingUsageDescription</key>
<string>This identifier will be used to deliver personalized ads to you.</string>
- Allow HTTP requests to localhost. Add the following configuration to allow HTTP requests specifically to localhost:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>localhost</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>
</dict>
- Declare the library in Podfile:
pod 'SSAITracking', :git => 'https://github.com/sigmaott/sigma-ssai-ios.git', :tag => '1.0.4'
- Run the installation command:
cd [path to your project]
pod install
- Import the SDK:
import SSAITracking
- Call the start function when your application launches:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
SSAITracking.SigmaSSAI.start()
return true
}
- Initialize the SDK with the required parameters:
self.ssai = SSAITracking.SigmaSSAI.init(adsEndpoint, self, playerView)
adsEndpoint
: Your ads endpoint (it will be obtained from the detailed endpoint information page in the SSAI product).self
: A reference to the current instance of your class, which must conform to theSigmaSSAIInterface
protocol to handle callbacks.playerView
: The view where the video player will be displayed.
Once the SDK is initialized, generate the video URL by calling the generateUrl
method with the videoUrl
parameter:
Note: If the videoUrl
contains the query parameter sigma.dai.adsEndpoint
, its value will override the adsEndpoint
provided during initialization.
Example: https://example.com/master.m3u8?sigma.dai.adsEndpoint=abc123
self.ssai?.generateUrl(videoUrl)
After calling generateUrl
, listen for callbacks from the SDK:
- Success Callback:
When the video URL is successfully generated, the
onGenerateVideoUrlSuccess
method will be called. - Failure Callback:
If there is an error generating the video URL, the
onGenerateVideoUrlFail
method will be invoked.
Always remember to call setPlayer
on the SDK after initializing the AVPlayer
or replacing the current item. This ensures that the SDK correctly recognizes the active video player and can effectively manage ad tracking. If you need to change the adsEndpoint
, it is essential to reinitialize the SDK. This ensures that the new endpoint is properly configured and used for tracking.
onGenerateVideoUrlSuccess(_ videoUrl: String)
: Called when the video URL is successfully generated.onGenerateVideoUrlFail(_ message: String)
: Called when there is an error in generating the video URL.onTracking(_ message: String)
: Called whenever there is a tracking message.
By following the steps outlined above, you can successfully integrate and utilize the SSAITracking SDK within your application. Ensure that you handle both success and failure callbacks to provide a seamless user experience.
- SSAITracking demo link: Demo Link