Menu

iOS SDK Integration (Advertising SDK)

  • Advertising SDK is used to support Apple Search Ads (Apple Search Advertising, referred to as ASA) activation attribution, can track the user's activation and post-link behavior in the full link, and support the front and back link connection, with Shenze advertising analysis products for channel analysis;
  • Advertising SDK relies onSensors Analytics SDK 2.6.3 and above. Before use, please ensure that the SDK has been successfully integrated and the SDK has been initialized. For details, seeSDK 集成 (iOS)SDK integrated(macOS).

Integration step

CocoaPods method

  • In Podfile file add pod  'SensorsAdvertising' 
  • Open the terminal and switch to the project directory
  • Excute pod install or pod update SensorsAdvertising


Note

  1. pod strongly recommends using use_frameworks! Subsequent advertising SDK packages will exist in the form of xcframework.
  2. If excute pod update The latest version cannot be detected. You can run pod cache clean SensorsAdvertising first to clear local cache.

Source code mode

  • From GitHub get SDK source code ;
  • Put SDK(SensorsAdvertising SensorsAdvertising SensorsAdvertising.framework )import App project,and select Copy items if needed

Procedure of use

The IDFA authorization description is added

In the info. Add NSUserTrackingUsageDescription authorization description file.

Import header file

Import the SensorsAdvertising header file in AppDelegate.m

#import <SensorsAdvertising/SensorsAdvertising.h>

Initialize the SDK

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 	// 初始化 SensorsAnalytics SDK NSString *serverURL = @"http://xxxxx"; SAConfigOptions *saconfigOptions = [[SAConfigOptions alloc] initWithServerURL:serverURL launchOptions:launchOptions];    saConfigOptions.autoTrackEventType = SensorsAnalyticsEventTypeAppStart | SensorsAnalyticsEventTypeAppEnd | SensorsAnalyticsEventTypeAppClick | SensorsAnalyticsEventTypeAppViewScreen;    saConfigOptions.enableLog = YES; [SensorsAnalyticsSDK startWithConfigOptions:saConfigOptions]; // 初始化 SensorsAdvertising SDK SADConfigOptions *sadconfigOptions = [[SADConfigOptions alloc] initWithLaunchOptions:launchOptions]; // sadconfigOptions 配置 	// ... [SensorsAdvertising startWithConfigOptions:sadconfigOptions]; // 其他业务处理 // ... return YES; }

Note

  1. The advertising SDK relies on SensorsAnalyticsSDK, so SensorsAnalyticsSDK needs to be initialized first
  2. The advertising SDK automatically collects activation events, and the original activation event interface should not be manually called
  3. If the original recorded activation event name is not $AppInstall, you need to use virtual event to merge the original activation event and $AppInstall for analysis. Please consult the on-call colleague for details
  4. Configure the parameters for the original activation event interface through SADConfigOptions
    1. appInstallProperties: custom properties in the activation event

    2. disableAppInstallCallback: disable the callback request for channel matching in the activation event

autoRequestTrackingAuthorization

By default, the advertising SDK will request IDFA authorization. If you don't want the SDK to automatically request IDFA authorization, you can configure autoRequestTrackingAuthorization = NO

When autoRequestTrackingAuthorization = NO, you must call the advertising SDK interface to pass the authorization status to the SDK

- (void)applicationDidBecomeActive:(UIApplication *)application { if (@available(iOS 14, *)) { [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {         		[SensorsAdvertising.sharedInstance setTrackingAuthorizationStatus:status];    }]; }   }

Note

The setTrackingAuthorizationStatus: interface must be called after the initialization of SensorsAdvertising SDK

Previous
iOS SDK integration (excluding IDFA-Advertising SDK)
Next
SDK Function Introduction
Last modified: 2025-01-02