Basic Integration

Updated at:

1. Domain name settings

Before initialization, call the setCustomDomain interface before any other SDK interface to set the data collection domain for your private environment.

Interface:

/** Set the primary and alternative domain names for reporting statistical logs. Call this function before initializing the SDK.
*
@param primaryDomain The primary domain name for log collection. This parameter cannot be null or an empty string.
@param standbyDomain The alternative domain name for log collection. This parameter can be null or an empty string. If it is empty, the SDK automatically uses the primary domain as the alternative domain.
*/

+ (void)setCustomDomain:(NSString *)primaryDomain standbyDomain:(NSString *)standbyDomain;

Parameters:

Parameter

Type

Description

Note

primaryDomain

NSString

Primary domain name

Required

standbyDomain

NSString

Alternative domain name

Optional

Example:

#import <UMAPM/UMAPMConfig.h>
#import <UMAPM/UMCrashConfigure.h>
#import <UMEFS/UMEFS.h>
#import <UMEFS/UMEFSConfig.h>
#import <UMEFS/UMEFSConfigure.h>
#import <QTCommon/QTCommon.h>
#import <UMCommonLog/UMCommonLogManager.h> // Add this when importing the logging package

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    UMAPMConfig* config = [UMAPMConfig defaultConfig];   
    config.crashAndBlockMonitorEnable = YES;
    [UMCrashConfigure setAPMConfig:config];

    UMEFSConfig* configForEFS = [UMEFSConfig defaultConfig];
    configForEFS.networkEnable = YES;
    configForEFS.launchMonitorEnable = YES;
    configForEFS.memMonitorEnable = YES;
    configForEFS.javaScriptBridgeEnable = YES;
    configForEFS.oomMonitorEnable = YES;
    configForEFS.pageMonitorEnable = YES;
    configForEFS.logCollectEnable = YES;
    configForEFS.logCollectUserId = @"user1";
    configForEFS.initSendPVEnable = YES;
    [UMEFSConfigure setAPMConfig:configForEFS];

    [QTConfigure setCustomDomain:@"your-data-collection-domain" standbyDomain:@""];
    [QTConfigure initWithAppkey:@"your-appkey" channel:@"App Store"];
  
    return YES;
}

2. Set device ID (optional)

The APM SDK uses the device ID generated by the QTCommon SDK and enforces strict validation. If you customize the device ID (see 2.1 Device ID settings), it must meet these requirements:

  • Length: 16–34 characters

  • Type: uppercase letters, lowercase letters, or digits

3. Set user ID (optional)

Interface:

+ (void)profileSignInWithPUID:(NSString *)puid;
+ (void)profileSignOff;

Parameters:

Parameter

Type

Description

Note

puid

NSString

User ID

Example:

[QTMobClick profileSignInWithPUID:@"UserID"];

4. Enable statistics (initialization)

4.1 Initialization interface

Initialization enables statistical features. To comply with MIIT regulations, do not call the initialization function until the user has read your Privacy Policy and granted consent during the first cold launch. The SDK collects device information and reports data only after consent is granted. If the user does not consent, do not initialize the SDK.

/** Initialize all component products.
 @param appKey The appkey you requested from QT.
 @param channel The channel identifier. Set to nil to indicate "App Store".
 */
+ (void)initWithAppkey:(NSString *)appKey channel:(NSString *)channel;

After the user consents, call the initialization function on every subsequent cold launch.

4.2. Get Appkey

Go to Management Console > Application Management to find your app and obtain its Appkey.

5. Enable logging

Interface:

+ (void)setLogEnable:(BOOL)enable;

To view SDK initialization logs, enable logging before calling the domain setup and initialization interfaces.

Header file:

#import <UMEFS/WPKLog.h>

Example:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    [UMCommonLogManager setUpUMCommonLogManager];
    [QTConfigure setLogEnabled:YES]; // Enable data statistics logging
    [WPKLog setLogEnable:YES]; // Enable performance experience logging
    [QTConfigure setCustomDomain:@"your-data-collection-domain" standbyDomain:nil]; // Set data collection domain
    [QTConfigure initWithAppkey:@"your-appkey" channel:@"App Store"];
}