iOS SDK - 方法参考
本综合参考文档记录了适用于 iOS 应用程序的 Singular SDK 中所有可用的方法。该 SDK 提供了用于初始化、事件追踪、收入报告、归因、数据隐私合规以及配置的功能。每个方法都附有说明、签名和实用的使用示例,以帮助开发者将 Singular SDK 的功能集成到他们的应用程序中。
adRevenue
Singular.adRevenue 方法
使用详细的广告数据信息追踪广告收入事件。此方法允许您报告应用程序中显示的广告所产生的收入,并使用各种参数对广告效果进行分类和分析。
签名
+ (void)adRevenue:(SingularAdData *)adData;
使用示例
// Create ad data object
let adData = SingularAdData(adPlatform: "AdMob",
withCurrency: "USD",
withRevenue: 0.05)
adData.adUnitId = "ca-app-pub-123456789/1234567890"
adData.adType = "Rewarded"
adData.adPlacementName = "level_complete"
// Track ad revenue event
Singular.adRevenue(adData)
// Create ad data object
SingularAdData *adData = [[SingularAdData alloc] initWithAdPlatform:@"AdMob"
withCurrency:@"USD"
withRevenue:0.05];
adData.adUnitId = @"ca-app-pub-123456789/1234567890";
adData.adType = @"Rewarded";
adData.adPlacementName = @"level_complete";
// Track ad revenue event
[Singular adRevenue:adData];
clearGlobalProperties
Singular.clearGlobalProperties 方法
移除所有先前设置的全局归因。当您需要重置全局归因时(例如用户从您的应用程序注销时),此方法非常有用。
签名
+ (void)clearGlobalProperties;
使用示例
// Clear all global properties
Singular.clearGlobalProperties()
// Clear all global properties
[Singular clearGlobalProperties];
createReferrerShortLink
Singular.createReferrerShortLink 方法
创建带有推荐人信息的短链接,可用于分享和归因。此方法生成可追踪的链接,可以与用户分享,从而将安装和活动归因到特定的推荐来源。
签名
+ (void)createReferrerShortLink:(NSString *)baseLink
referrerName:(NSString *)referrerName
referrerId:(NSString *)referrerId
completionHandler:(void (^)(NSString *, NSError *))completionHandler;
+ (void)createReferrerShortLink:(NSString *)baseLink
referrerName:(NSString *)referrerName
referrerId:(NSString *)referrerId
passthroughParams:(NSDictionary *)passthroughParams
completionHandler:(void (^)(NSString *, NSError *))completionHandler;
使用示例
// Create a short link for referral
Singular.createReferrerShortLink("https://sample.sng.link/B4tbm/v8fp",
referrerName: "John Doe",
referrerId: "aq239897",
passthroughParams: [
"channel": "sms",
"campaign": "summer_promo"
]) { link, error in
if let error = error {
print("Error creating short link: \(error)")
} else if let link = link {
print("Generated short link: \(link)")
// Share the link with users
}
}
// Create a short link for referral
[Singular createReferrerShortLink:@"https://sample.sng.link/B4tbm/v8fp"
referrerName:@"John Doe"
referrerId:@"aq239897"
passthroughParams:@{
@"channel": @"sms",
@"campaign": @"summer_promo"
}
completionHandler:^(NSString *link, NSError *error) {
if (error) {
NSLog(@"Error creating short link: %@", error);
} else {
NSLog(@"Generated short link: %@", link);
// Share the link with users
}
}];
customRevenue
Singular.customRevenue 方法
使用指定的事件名称、货币、金额和可选的产品信息追踪自定义收入事件。这允许使用自定义事件名称进行更具体的收入追踪。
签名
+ (void)customRevenue:(NSString *)eventname
transaction:(id)transaction;
+ (void)customRevenue:(NSString *)eventname
transaction:(id)transaction
withAttributes:(NSDictionary *)attributes;
+ (void)customRevenue:(NSString *)eventname
currency:(NSString *)currency
amount:(double)amount;
+ (void)customRevenue:(NSString *)eventname
currency:(NSString *)currency
amount:(double)amount
withAttributes:(NSDictionary *)attributes;
+ (void)customRevenue:(NSString *)eventname
currency:(NSString *)currency
amount:(double)amount
productSKU:(NSString *)productSKU
productName:(NSString *)productName
productCategory:(NSString *)productCategory
productQuantity:(int)productQuantity
productPrice:(double)productPrice;
+ (void)customRevenue:(NSData *)transactionJsonRepresentation
productJsonRepresentation:(NSData *)productJsonRepresentation;
+ (void)customRevenue:(NSString *)eventName
transactionJsonRepresentation:(NSData *)transactionJsonRepresentation
productJsonRepresentation:(NSData *)productJsonRepresentation;
+ (void)customRevenue:(NSString *)eventName
transactionJsonRepresentation:(NSData *)transactionJsonRepresentation
productJsonRepresentation:(NSData *)productJsonRepresentation
withAttributes:(NSDictionary *)attributes;
使用示例
// Track a custom revenue event
Singular.customRevenue("premium_subscription",
currency: "USD",
amount: 9.99)
// Track a custom revenue event with attributes
Singular.customRevenue("in_app_purchase",
currency: "USD",
amount: 5.99,
withAttributes: [
"product_id": "com.app.gems_pack_small",
"quantity": 1
])
// Track a custom revenue event from a StoreKit transaction
if let transactionData = transaction.payment.requestData,
let productData = try? JSONSerialization.data(withJSONObject: [
"productID": transaction.payment.productIdentifier
]) {
Singular.customRevenue("in_app_purchase",
transactionJsonRepresentation: transactionData,
productJsonRepresentation: productData,
withAttributes: ["source": "store"])
}
// Track a custom revenue event
[Singular customRevenue:@"premium_subscription"
currency:@"USD"
amount:9.99];
// Track a custom revenue event with attributes
[Singular customRevenue:@"in_app_purchase"
currency:@"USD"
amount:5.99
withAttributes:@{
@"product_id": @"com.app.gems_pack_small",
@"quantity": @1
}];
// Track a custom revenue event from a StoreKit transaction
NSData *transactionData = transaction.payment.requestData;
NSData *productData = [NSJSONSerialization
dataWithJSONObject:@{@"productID": transaction.payment.productIdentifier}
options:0
error:nil];
if (transactionData && productData) {
[Singular customRevenue:@"in_app_purchase"
transactionJsonRepresentation:transactionData
productJsonRepresentation:productData
withAttributes:@{@"source": @"store"}];
}
event
Singular.event 方法
使用指定的名称和可选的自定义归因追踪事件。使用这些方法来追踪应用程序中的用户操作和互动。
签名
+ (void)event:(NSString *)name;
+ (void)event:(NSString *)name withArgs:(NSDictionary *)args;
+ (void)eventWithArgs:(NSString *)name, ...;
使用示例
// Track a simple event
Singular.event("level_completed")
// Track an event with additional parameters
Singular.event("level_completed", withArgs: [
"level_id": 5,
"score": 12500,
"time_spent": 120,
"difficulty": "medium"
])
// Track a simple event
[Singular event:@"level_completed"];
// Track an event with additional parameters
[Singular event:@"level_completed"
withArgs:@{
@"level_id": @5,
@"score": @12500,
@"time_spent": @120,
@"difficulty": @"medium"
}];
// Track an event with variable arguments
[Singular eventWithArgs:@"purchase",
@"item_id", @"sword_01",
@"price", @9.99,
nil];
getGlobalProperties
Singular.getGlobalProperties 方法
获取当前设置的所有全局归因。此方法返回一个字典,其中包含为 SDK 设置的所有全局归因。
签名
+ (NSDictionary *)getGlobalProperties;
使用示例
// Get all global properties
let properties = Singular.getGlobalProperties()
print("Global properties: \(properties)")
// Get all global properties
NSDictionary *properties = [Singular getGlobalProperties];
NSLog(@"Global properties: %@", properties);
getLimitDataSharing
Singular.getLimitDataSharing 方法
获取当前的数据共享限制状态。此方法返回一个布尔值,指示数据共享当前是否受到限制。
签名
+ (BOOL)getLimitDataSharing;
使用示例
// Check if data sharing is limited
let isLimited = Singular.getLimitDataSharing()
if isLimited {
print("Data sharing is currently limited")
}
// Check if data sharing is limited
BOOL isLimited = [Singular getLimitDataSharing];
if (isLimited) {
NSLog(@"Data sharing is currently limited");
}
handlePushNotification
Singular.handlePushNotification 方法
处理用于归因的推送通知有效负载。当您的应用程序接收到推送通知时,应调用此方法,以便 Singular 正确地进行归因。
签名
+ (BOOL)handlePushNotification:(NSDictionary *)pushNotificationPayload;
使用示例
// Handle a received push notification
func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void) {
let userInfo = response.notification.request.content.userInfo
Singular.handlePushNotification(userInfo)
completionHandler()
}
// Handle a received push notification
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response
withCompletionHandler:(void (^)(void))completionHandler {
NSDictionary *userInfo = response.notification.request.content.userInfo;
[Singular handlePushNotification:userInfo];
completionHandler();
}
iapComplete
Singular.iapComplete 方法
追踪应用内购买完成事件。这些方法应在应用内购买交易完成时调用。
签名
+ (void)iapComplete:(id)transaction;
+ (void)iapComplete:(id)transaction
withName:(NSString *)name;
+ (void)iapComplete:(id)transaction
withAttributes:(id)value, ...;
+ (void)iapComplete:(id)transaction
withName:(NSString *)name
withAttributes:(id)value, ...;
使用示例
// Track IAP completion
Singular.iapComplete(transaction)
// Track IAP completion with custom name
Singular.iapComplete(transaction, withName: "premium_upgrade")
// Track IAP completion
[Singular iapComplete:transaction];
// Track IAP completion with custom name
[Singular iapComplete:transaction
withName:@"premium_upgrade"];
// Track IAP completion with attributes
[Singular iapComplete:transaction
withAttributes:@"user_level", @42,
@"is_first_purchase", @YES,
nil];
isAllTrackingStopped
Singular.isAllTrackingStopped 方法
检查所有追踪是否当前已停止。此方法返回一个布尔值,指示追踪当前是否已停止。
签名
+ (BOOL)isAllTrackingStopped;
使用示例
// Check if tracking is stopped
if Singular.isAllTrackingStopped() {
print("Tracking is currently stopped")
}
// Check if tracking is stopped
if ([Singular isAllTrackingStopped]) {
NSLog(@"Tracking is currently stopped");
}
isSingularLink
Singular.isSingularLink 方法
返回给定的链接持有者(通常是
NSURL
或
NSUserActivity)是否代表 Singular Link。当 Singular 将通过 SDK 的
singularLinksHandler 解析链接时,使用此方法可以提前结束您自己的深度链接处理。
签名
+ (BOOL)isSingularLink:(id)linkHolder;
使用示例
// Inspect an incoming URL before handling it yourself
func application(_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
if Singular.isSingularLink(url) {
// Singular's singularLinksHandler will receive the resolved link.
return true
}
// Fall through to your own deep-link handling
return handleCustomURL(url)
}
// Inspect an incoming URL before handling it yourself
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
if ([Singular isSingularLink:url]) {
// Singular's singularLinksHandler will receive the resolved link.
return YES;
}
return [self handleCustomURL:url];
}
limitDataSharing
Singular.limitDataSharing 方法
设置数据共享限制状态。使用此方法根据用户同意或隐私要求来限制数据共享。
签名
+ (void)limitDataSharing:(BOOL)shouldLimitDataSharing;
使用示例
// To limit data sharing (e.g., when user opts out)
Singular.limitDataSharing(true)
// To enable full data sharing (e.g., when user opts in)
Singular.limitDataSharing(false)
// To limit data sharing (e.g., when user opts out)
[Singular limitDataSharing:YES];
// To enable full data sharing (e.g., when user opts in)
[Singular limitDataSharing:NO];
registerDeviceTokenForUninstall
Singular.registerDeviceTokenForUninstall 方法
为卸载追踪注册设备令牌。应使用推送通知令牌调用此方法,以启用卸载追踪。
签名
+ (void)registerDeviceTokenForUninstall:(NSData *)deviceToken;
使用示例
// Register device token for uninstall tracking
func application(_ application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
Singular.registerDeviceTokenForUninstall(deviceToken)
}
// Register device token for uninstall tracking
- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
[Singular registerDeviceTokenForUninstall:deviceToken];
}
resumeAllTracking
Singular.resumeAllTracking 方法
恢复所有先前停止的追踪活动。使用此方法在追踪停止后重新启用追踪。
签名
+ (void)resumeAllTracking;
使用示例
// Resume tracking when user opts back in
Singular.resumeAllTracking()
// Resume tracking when user opts back in
[Singular resumeAllTracking];
revenue
Singular.revenue 方法
使用包括货币、金额和产品详情等各种参数追踪收入事件。这允许对您的应用程序进行全面的收入追踪。
签名
+ (void)revenue:(id)transaction;
+ (void)revenue:(id)transaction withAttributes:(NSDictionary *)attributes;
+ (void)revenue:(NSString *)currency amount:(double)amount;
+ (void)revenue:(NSString *)currency
amount:(double)amount
withAttributes:(NSDictionary *)attributes;
+ (void)revenue:(NSString *)currency
amount:(double)amount
productSKU:(NSString *)productSKU
productName:(NSString *)productName
productCategory:(NSString *)productCategory
productQuantity:(int)productQuantity
productPrice:(double)productPrice;
使用示例
// Track revenue with currency and amount
Singular.revenue("USD", amount: 9.99)
// Track revenue with additional attributes
Singular.revenue("USD", amount: 19.98, withAttributes: [
"product_id": "premium_gems",
"quantity": 2
])
// Track revenue with detailed product information
Singular.revenue("USD",
amount: 19.98,
productSKU: "SKU123456",
productName: "Premium Sword",
productCategory: "Weapons",
productQuantity: 2,
productPrice: 9.99)
// Track revenue from a StoreKit SKPaymentTransaction
// (typically inside SKPaymentTransactionObserver.paymentQueue(_:updatedTransactions:))
func paymentQueue(_ queue: SKPaymentQueue,
updatedTransactions transactions: [SKPaymentTransaction]) {
for transaction in transactions where transaction.transactionState == .purchased {
Singular.revenue(transaction)
SKPaymentQueue.default().finishTransaction(transaction)
}
}
// Track revenue with currency and amount
[Singular revenue:@"USD" amount:9.99];
// Track revenue with additional attributes
[Singular revenue:@"USD"
amount:19.98
withAttributes:@{
@"product_id": @"premium_gems",
@"quantity": @2
}];
// Track revenue with detailed product information
[Singular revenue:@"USD"
amount:19.98
productSKU:@"SKU123456"
productName:@"Premium Sword"
productCategory:@"Weapons"
productQuantity:2
productPrice:9.99];
// Track revenue from a StoreKit SKPaymentTransaction
// (typically inside paymentQueue:updatedTransactions:)
- (void)paymentQueue:(SKPaymentQueue *)queue
updatedTransactions:(NSArray<SKPaymentTransaction *> *)transactions {
for (SKPaymentTransaction *transaction in transactions) {
if (transaction.transactionState == SKPaymentTransactionStatePurchased) {
[Singular revenue:transaction];
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
}
}
}
setCustomUserId
Singular.setCustomUserId 方法
为当前用户设置自定义用户 ID。这允许您将 Singular 数据与您自己的用户识别系统关联起来。
签名
+ (void)setCustomUserId:(NSString *)customUserId;
使用示例
// Set custom user ID after user logs in
Singular.setCustomUserId("user_123456")
// Set custom user ID after user logs in
[Singular setCustomUserId:@"user_123456"];
setDeviceCustomUserId
已弃用功能: 请改用 setCustomUserId。
Singular.setDeviceCustomUserId 方法
在设备级别设置自定义用户 ID。这允许您在设备级别将 Singular 数据与您自己的用户识别系统关联起来。
签名
+ (void)setDeviceCustomUserId:(NSString *)customUserId;
使用示例
// Set device-level custom user ID
Singular.setDeviceCustomUserId("device_user_123456")
// Set device-level custom user ID
[Singular setDeviceCustomUserId:@"device_user_123456"];
setGlobalProperty
Singular.setGlobalProperty 方法
设置将随所有事件一起发送的全局归因。这允许您为所有事件添加一致的归因,而无需每次都指定它们。
签名
+ (BOOL)setGlobalProperty:(NSString *)key
andValue:(NSString *)value
overrideExisting:(BOOL)overrideExisting;
使用示例
// Set a global property
let success = Singular.setGlobalProperty("user_tier",
andValue: "premium",
overrideExisting: true)
if success {
print("Global property set successfully")
}
// Set a global property
BOOL success = [Singular setGlobalProperty:@"user_tier"
andValue:@"premium"
overrideExisting:YES];
if (success) {
NSLog(@"Global property set successfully");
}
setLimitAdvertisingIdentifiers
Singular.setLimitAdvertisingIdentifiers 方法
在运行时启用或禁用广告标识符收集的限制。这是配置时归因
SingularConfig.limitAdvertisingIdentifiers
的运行时等价物,可以在
Singular.start(_:) 之后的任意时间点进行切换。
此方法在 Singular Kids SDK 构建中已被编译排除(受
#ifndef SINGULAR_KIDS 保护)。如果您正在集成
Singular-Kids-SDK,则此方法不可用。Kids SDK 会自动强制执行更严格的标识符处理。
签名
+ (void)setLimitAdvertisingIdentifiers:(BOOL)enabled;
使用示例
// Limit advertising identifiers at runtime (e.g., after a consent dialog)
Singular.setLimitAdvertisingIdentifiers(true)
// Limit advertising identifiers at runtime (e.g., after a consent dialog)
[Singular setLimitAdvertisingIdentifiers:YES];
setLoggingEnabled
Singular.setLoggingEnabled 方法
在运行时切换 SDK 日志记录。
SingularConfig.enableLogging 的运行时对应方法。在此值为
YES
且
setLogLevel:
设置高于
SingularLogLevelNone 之前,日志记录处于静默状态。
签名
+ (void)setLoggingEnabled:(BOOL)enabled;
使用示例
// Enable SDK logging for debug builds
#if DEBUG
Singular.setLoggingEnabled(true)
Singular.setLogLevel(.debug)
#endif
// Enable SDK logging for debug builds
#ifdef DEBUG
[Singular setLoggingEnabled:YES];
[Singular setLogLevel:SingularLogLevelDebug];
#endif
setLogLevel
Singular.setLogLevel 方法
在运行时设置 SDK 日志详细程度。
SingularConfig.logLevel 的运行时对应方法。可用级别在
SingularLogLevel.h 中定义:
SingularLogLevelNone、
SingularLogLevelError、
SingularLogLevelWarning、
SingularLogLevelInfo、
SingularLogLevelDebug、
SingularLogLevelVerbose。
签名
+ (void)setLogLevel:(SingularLogLevel)logLevel;
使用示例
// Set verbose logging for detailed debugging
Singular.setLoggingEnabled(true)
Singular.setLogLevel(.verbose)
// Set verbose logging for detailed debugging
[Singular setLoggingEnabled:YES];
[Singular setLogLevel:SingularLogLevelVerbose];
setSessionTimeout
Singular.setSessionTimeout 方法
设置会话超时时间(以秒为单位)。这决定了应用程序进入后台后用户会话持续的时间。
签名
+ (void)setSessionTimeout:(int)timeout;
使用示例
// Set session timeout to 2 minutes
Singular.setSessionTimeout(120)
// Set session timeout to 2 minutes
[Singular setSessionTimeout:120];
skanGetConversionValue
Singular.skanGetConversionValue 方法
获取当前的 SKAdNetwork 转化值。此方法返回用于 SKAdNetwork 归因的当前转化值。
签名
+ (NSNumber *)skanGetConversionValue;
使用示例
// Get the current SKAdNetwork conversion value
let conversionValue = Singular.skanGetConversionValue()
print("Current conversion value: \(conversionValue ?? 0)")
// Get the current SKAdNetwork conversion value
NSNumber *conversionValue = [Singular skanGetConversionValue];
NSLog(@"Current conversion value: %@", conversionValue);
skanRegisterAppForAdNetworkAttribution
Singular.skanRegisterAppForAdNetworkAttribution 方法
为 SKAdNetwork 归因注册应用程序。应调用此方法以在 iOS 上启用 SKAdNetwork 归因。
签名
+ (void)skanRegisterAppForAdNetworkAttribution;
使用示例
// Register for SKAdNetwork attribution
Singular.skanRegisterAppForAdNetworkAttribution()
// Register for SKAdNetwork attribution
[Singular skanRegisterAppForAdNetworkAttribution];
skanUpdateConversionValue
Singular.skanUpdateConversionValue 方法
更新 SKAdNetwork 转化值。这些方法允许您手动更新用于 SKAdNetwork 归因的转化值。
签名
+ (BOOL)skanUpdateConversionValue:(NSInteger)conversionValue;
+ (void)skanUpdateConversionValue:(NSInteger)conversionValue
coarse:(NSInteger)coarse
lock:(BOOL)lock;
使用示例
// Update the SKAdNetwork conversion value
let success = Singular.skanUpdateConversionValue(5)
if success {
print("Conversion value updated successfully")
}
// Update SKAdNetwork 4.0 conversion values (iOS 16.1+)
Singular.skanUpdateConversionValue(5, // fine value (0-63)
coarse: 1, // coarse value (0=low, 1=medium, 2=high)
lock: false)
// Update the SKAdNetwork conversion value
BOOL success = [Singular skanUpdateConversionValue:5];
if (success) {
NSLog(@"Conversion value updated successfully");
}
// Update SKAdNetwork 4.0 conversion values (iOS 16.1+)
[Singular skanUpdateConversionValue:5 // fine value (0-63)
coarse:1 // coarse value (0=low, 1=medium, 2=high)
lock:NO];
start
Singular.start 方法
使用提供的配置初始化 Singular SDK。这是您开始使用 Singular SDK 时应调用的第一个方法。
签名
+ (BOOL)start:(SingularConfig *)config;
使用示例
// Create configuration object
let config = SingularConfig(apiKey: "SDK_KEY", andSecret: "SDK_SECRET")
// Configure additional options if needed
config.customUserId = "user-123456"
config.sessionTimeout = 60
// Initialize the SDK
Singular.start(config)
// Create configuration object
SingularConfig *config = [[SingularConfig alloc] initWithApiKey:@"SDK_KEY" andSecret:@"SDK_SECRET"];
// Configure additional options if needed
config.customUserId = @"user-123456";
config.sessionTimeout = 60;
// Initialize the SDK
[Singular start:config];
startSession
Singular.startSession 方法
使用 Singular SDK 启动新会话。多种变体可用于不同的初始化场景,包括启动选项、用户活动和深度链接处理。
签名
+ (void)startSession:(NSString *)apiKey withKey:(NSString *)apiSecret;
+ (BOOL)startSession:(NSString *)apiKey
withKey:(NSString *)apiSecret
andLaunchOptions:(NSDictionary *)launchOptions
withSingularLinkHandler:(void (^)(SingularLinkParams *))handler;
+ (BOOL)startSession:(NSString *)apiKey
withKey:(NSString *)apiSecret
andLaunchOptions:(NSDictionary *)launchOptions
withSingularLinkHandler:(void (^)(SingularLinkParams *))handler
andShortLinkResolveTimeout:(long)timeoutSec;
+ (void)startSession:(NSString *)apiKey
withKey:(NSString *)apiSecret
andLaunchOptions:(NSDictionary *)launchOptions;
使用示例
// Simple session start
Singular.startSession("API_KEY", withKey: "API_SECRET")
// Session start with deep link handler
Singular.startSession("API_KEY",
withKey: "API_SECRET",
andLaunchOptions: launchOptions,
withSingularLinkHandler: { params in
if let deeplink = params.deeplink {
print("Deep link received: \(deeplink)")
}
})
// Simple session start
[Singular startSession:@"API_KEY" withKey:@"API_SECRET"];
// Session start with deep link handler
[Singular startSession:@"API_KEY"
withKey:@"API_SECRET"
andLaunchOptions:launchOptions
withSingularLinkHandler:^(SingularLinkParams *params) {
NSLog(@"Deep link received: %@", params.deeplink);
}];
stopAllTracking
Singular.stopAllTracking 方法
停止所有追踪活动。使用此方法在用户选择退出或出于隐私合规考虑时禁用追踪。
签名
+ (void)stopAllTracking;
使用示例
// Stop tracking when user opts out
Singular.stopAllTracking()
// Stop tracking when user opts out
[Singular stopAllTracking];
trackingOptIn
Singular.trackingOptIn 方法
表明用户已选择启用追踪。当用户明确同意追踪和数据收集时,调用此方法。
签名
+ (void)trackingOptIn;
使用示例
// User has opted in to tracking
Singular.trackingOptIn()
// User has opted in to tracking
[Singular trackingOptIn];
trackingUnder13
Singular.trackingUnder13 方法
表明用户未满 13 岁。调用此方法以遵守 COPPA 和针对 13 岁以下用户的其他法规。
签名
+ (void)trackingUnder13;
使用示例
// Notify Singular the user is under 13 years old
Singular.trackingUnder13()
// Notify Singular the user is under 13 years old
[Singular trackingUnder13];
unsetCustomUserId
Singular.unsetCustomUserId 方法
移除先前设置的自定义用户 ID。当用户注销或您不再希望将事件与当前用户 ID 关联时,调用此方法。
签名
+ (void)unsetCustomUserId;
使用示例
// Clear custom user ID when user logs out
Singular.unsetCustomUserId()
// Clear custom user ID when user logs out
[Singular unsetCustomUserId];
unsetGlobalProperty
Singular.unsetGlobalProperty 方法
移除先前设置的全局归因。当您不再希望某个特定的全局归因随事件一起发送时,调用此方法。
签名
+ (void)unsetGlobalProperty:(NSString *)key;
使用示例
// Remove a global property
Singular.unsetGlobalProperty("user_tier")
// Remove a global property
[Singular unsetGlobalProperty:@"user_tier"];