iOS SDK: Adding SKAdNetwork Support

Singular iOS SDK
Download
Singular iOS SDK version 11.0.0
Compatibility iOS 8+
Sample App

Our sample app includes a complete integration of the Singular SDK. Review the code to see how the different parts of the integration come together using best practices.

Integration Guides
  1. Basic Integration
  2. Tracking Events and Revenue
  3. Implementing Deep Links
  4. Adding SKAdNetwork Support
  5. Advanced Options

 

Introduction: SKAdNetwork and SKAN

SKAdNetwork is Apple's new framework for determining mobile install attribution without compromising the end user's privacy. SKAdNetwork lets you measure the performance of your app marketing campaigns without sharing the user's personally identifiable information.

Singular's new version of the iOS SDK helps you implement SKAdNetwork seamlessly and with minimal engineering effort. For more information, see Introduction to Singular's SKAdNetwork Solution.

Enabling SKAdNetwork Tracking

To enable SKAdNetwork tracking for your app, turn on the skAdNetworkEnabled configuration option before initializing Singular:

// instantiate SingularConfig
SingularConfig* config = [[SingularConfig alloc] initWithApiKey:apiKey andSecret:secretKey];
// add the skAdNetworkEnabled option and set it to YES
config.skAdNetworkEnabled = YES;
// start
[Singular start:config];

Handling Conversion Value Updates

Managed Mode

By default, the SKAdNetwork implementation manages the conversion value directly from the Singular server side.

This allows for maximum flexibility as you can set and change your conversion values through the Singular web app, without modifying your client-side code.

This server-side managed mode also helps you deal with the SKAdNetwork timers. SKAdNetwork allows you to update the conversion value within 24 hours from the time of registration to SKAdNetwork. Any call to update the conversion value extends the timer by 24 more hours. Therefore, when choosing your conversion events, you'll have to make sure the events happen within that update window. In managed mode, you can change the conversion event configuration at any time, without releasing a new version of your app.

Manual Mode

If you want to update the conversion value on your own in the app code, set manualSkanConversionManagement to YES when you initialize the SDK:

SingularConfig* config = 
[[SingularConfig alloc] initWithApiKey:apiKey andSecret:secretKey];
// Enable SKAdNetwork config.skAdNetworkEnabled = YES;
// Enable manual conversion value updates config.manualSkanConversionManagement = YES;
[Singular start:config];

Then, to update the conversion value, use the skanUpdateConversionValue method wherever needed in your app's lifecycle:

skanUpdateConversionValue Method (Objective-C)
Description Manually update the SKAdNetwork conversion value.
Signature + (BOOL)skanUpdateConversionValue:(NSInteger)conversionValue;
Usage Example
// signup event happened
[Singular event:@"SignUp"];
// update conversion value to 7 [Singular skanUpdateConversionValue:7];

Note: The skanUpdateConversionValue method will not function if you have not set manual updates to "yes". 

Retrieving the Conversion Value

To get the current conversion value, use the skanGetConversionValue method or conversionValueUpdatedCallback. Both work in managed and manual mode.

skanGetConversionValue Method (Objective-C)
Description Get the current conversion value tracked by the Singular SDK.
Signature + (NSNumber *)skanGetConversionValue;
Usage Example
NSNumber* conversionValue = [Singular skanGetConversionValue];
conversionValueUpdatedCallback Callback (Objective-C)
Description Get the current conversion value tracked by the Singular SDK.
Signature void(^conversionValueUpdatedCallback)(NSInteger);
Usage Example
SingularConfig* config = [[SingularConfig alloc] 
initWithApiKey:apiKey andSecret:secretKey];

// Enable SKAdNetwork config.skAdNetworkEnabled = YES;

config.conversionValueUpdatedCallback=^(NSInteger conversionValue) {
// Here you have access to the latest conversion value };
[Singular start:config];

Advanced Options

Delaying the Registration for SKAdNetwork

If you don't want to register for SKAdNetwork tracking right when you initialize the SDK, but at a later point in the app lifecycle, you can initialize the SDK with skAdNetworkEnabled = "no". Then, to register for SKAdNetwork, use the skanRegisterAppForAdNetworkAttribution method:

skanRegisterAppForAdNetworkAttribution Method (Objective-C) 
Description Register for SKAdNetwork tracking.
Signature + (void)skanRegisterAppForAdNetworkAttribution;
Usage Example
// Instantiate SingularConfig
SingularConfig* config = [[SingularConfig
alloc] initWithApiKey:apiKey andSecret:secretKey];
// Disable SKAdNetwork registration config.skAdNetworkEnabled = NO;
// start [Singular start:config];
// Later on - register for SKAdNetwork [Singular skanRegisterAppForAdNetworkAttribution];

Other iOS 14 Updates

Was this article helpful?