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歳未満であることを示します。13歳未満のユーザーに対するCOPPAおよびその他の規制に準拠するために、このメソッドを呼び出してください。
シグネチャ
+ (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"];