{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-@l10n/ja/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["admonition","partial"]},"type":"markdown"},"seo":{"title":"Treasure Data iOS SDK クイックスタート","description":"Treasure Data Product Documentation · Collect and Unify · Segment and Activate · Experiment and Analyze · Decisioning Automate with AI Scale and Trust.","siteUrl":"https://docs.treasuredata.com","lang":"en-US","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"ios-sdk-121-クイックスタート","__idx":0},"children":["iOS SDK 1.2.1 クイックスタート"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://www.treasuredata.com/"},"children":["Treasure Data"]},"用のiOSおよびtvOS SDKです。このSDKを使用すると、アプリケーションのイベントをTreasure Dataに簡単にインポートできます。このSDKは以下をサポートしています:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["iOS 12.0以上"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["tvOS 12.0以上"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"前提条件と要件","__idx":1},"children":["前提条件と要件"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["iOS開発の基礎知識(Xcode、CocoaPods)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["iOS 12.0以降"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Treasure Dataの基礎知識"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Treasure Data iOS SDKリリースへのアクセス"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["GDPRへの準拠の確保"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"tvos","__idx":2},"children":["tvOS"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["このSDKはApple tvOSバージョン12.0以上をサポートしています。APIとその動作は、iOSアプリケーションで使用される場合とほぼ同じですが、以下の点が異なります:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["tvOSでは、キャッシュストレージはいつでも削除される可能性のあるキャッシュディレクトリに保存されます。データの損失を防ぐため、イベントのアップロードAPIをできるだけ頻繁に呼び出すことをお勧めします。"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"バージョン101への移行","__idx":3},"children":["バージョン1.0.1への移行"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["バージョン1.0.1には、以前のバージョンとの後方互換性がない大きな変更があります。バージョン0.9.0以前からアップグレードする場合、以下の手順を実行しないとコードが正しく動作しません:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["APIエンドポイントがIngestionエンドポイントに変更されました。デフォルト値は[ https://us01.records.in.treasuredata.com ]です。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["initializeApiEndpoint"]}," APIは使用できなくなりました。代わりに",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["initializeWithApiKey:apiEndpoint:"]},"を使用してください。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["uuid"]},"は予約されたカラム名になりました。イベントの",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["uuid"]},"キーに値を追加しようとしても、データベースにそのカラムは表示されません。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_ip"]},"フィールドを追加することによるクライアントIDの自動トラッキングはサポートされなくなりました。代わりに、新しい",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#auto-tracking-device-ip"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["enableAutoTrackingIP"]}]},"および",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#auto-tracking-device-ip"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["disableAutoTrackingIP"]}]}," APIを使用してください。"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"swiftでの使用","__idx":4},"children":["Swiftでの使用"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["詳細については、この",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/treasure-data/td-ios-sdk/tree/master/TreasureDataExampleSwift"},"children":["Treasure Data Swiftサンプルプロジェクト"]},"を参照してください。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"インストール","__idx":5},"children":["インストール"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["ライブラリをインストールする方法はいくつかあります:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#option-1-cocoapods"},"children":["CocoaPods"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#option-2-swift-package-manager"},"children":["Swift Package Manager"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#option-3-framework"},"children":["Framework"]},"(非推奨)"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"オプション1-cocoapods","__idx":6},"children":["オプション1: CocoaPods"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["SDKをセットアップするには",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://guides.cocoapods.org/using/getting-started.html"},"children":["CocoaPods"]},"が必要です。まだインストールしていない場合は、最初にインストールしてください。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"gem install cocoapods\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["次に、Podfileに以下の行を追加します。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"ruby","header":{"controls":{"copy":{}}},"source":"pod 'TreasureData-iOS-SDK', '= 1.0.1'\n","lang":"ruby"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["SwiftでSDKを使用する場合は、Podfileに以下の行を追加します。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"ruby","header":{"controls":{"copy":{}}},"source":"use_frameworks!\n","lang":"ruby"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["最後に、'pod install'を実行します。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"pod install\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":[".xcodeproj"]},"ファイルではなく",{"$$mdtype":"Tag","name":"code","attributes":{},"children":[".xcworkspace"]},"ファイルを開いてプロジェクトを再度開くことを忘れないでください。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"オプション2-swift-package-manager","__idx":7},"children":["オプション2: Swift Package Manager"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Xcodeから",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["File > Swift Packages > Add Package Dependency"]},"を選択し、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["https://github.com/treasure-data/td-ios-sdk.git"]},"を入力してインストールできます。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["または、Package.swiftファイルの",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["dependencies"]},"配列に以下の行を追加します:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"swift","header":{"controls":{"copy":{}}},"source":".package(url: \"https://github.com/treasure-data/td-ios-sdk.git\", .upToNextMajor(from: \"1.0.1\"))\n","lang":"swift"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"オプション3-framework","__idx":8},"children":["オプション3: Framework"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["バージョン0.9.0以降、Treasure Dataはスタンドアロンフレームワークをサポートしていません。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"gdpr---個人情報のトラッキング","__idx":9},"children":["GDPR - 個人情報のトラッキング"]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info","name":"注意"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["収集すべき個人情報がある場合は、会社のデータプライバシー責任者および法務顧問とデータ収集ポリシーを確認する必要があります。個人のトラッキングを有効にする場合は、個々のユーザーのトラッキングへのオプトインを追跡するために、同意管理システムを統合することをお勧めします。"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["SDKは、多くの煩雑なif-else文に頼ることなく、デバイス全体のトラッキングを簡単にオプトアウトするための便利なメソッドを提供しています:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"objectivec","header":{"controls":{"copy":{}}},"source":"// 独自のイベントをオプトアウト\n[[TreasureData sharedInstance] disableCustomEvent];\n// TD生成イベントをオプトアウト\n[[TreasureData sharedInstance] disableAppLifecycleEvent];\n[[TreasureData sharedInstance] disableInAppPurchaseEvent];\n","lang":"objectivec"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["これらは",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["enableCustomEvent"]},"または",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["enableAppLifecycleEvent"]},"を呼び出すことで再度オプトインできます。これらの設定は永続的に保存されるため、アプリの起動をまたいで保持されます。一般的に、これらのメソッドは、SDKを初期化するたびではなく、ユーザーの選択を反映するときに呼び出す必要があります。デフォルトでは、カスタムイベントは有効で、アプリライフサイクルイベントは無効です。"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["resetUniqId"]},"を使用して、後続のイベントでデバイスの識別をリセットします。",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_uuid"]},"は別の値にランダム化され、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["{\"td_ios_event\": \"forget_device_id\", \"td_uuid\": <old_uuid>}"]},"を含む追加イベントが",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["defaultTable"]},"にキャプチャされます。"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["テストでは、収集している情報を確認して、意図した個人情報のみが含まれ、それ以上のものが含まれていないことを確認してください。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"基本的な使用方法-objective-c","__idx":10},"children":["基本的な使用方法: Objective-C"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["iOS SDKがインストールされた後、以下の手順により、書き込み専用APIキーでTreasureDataオブジェクトを初期化し、ローカルバッファにイベントを追加し、イベントのバッファをアップロードできます。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"sdkヘッダーファイルのインポート","__idx":11},"children":["SDKヘッダーファイルのインポート"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"objectivec","header":{"controls":{"copy":{}}},"source":"#import <TreasureData-iOS-SDK/TreasureData.h>\n","lang":"objectivec"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"treasure-apiキーの登録","__idx":12},"children":["Treasure APIキーの登録"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"objectivec","header":{"controls":{"copy":{}}},"source":"- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {\n    [TreasureData initializeWithApiKey:@\"your_api_key\"];\n}\n","lang":"objectivec"},"children":[]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["YOUR_API_KEY"]}," は、実際の apikey 文字列に置き換える必要があります。API キーは、Treasure コンソール のプロファイルから取得できます。",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/my-settings/getting-your-api-keys"},"children":["Write-only API key"]}," の使用が推奨されます。"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"ローカルバッファへのイベントの追加","__idx":13},"children":["ローカルバッファへのイベントの追加"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["ローカルバッファにイベントを追加するには、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TreasureData"]},"の",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["addEvent"]},"または",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["addEventWithCallback"]}," APIを呼び出します。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"objectivec","header":{"controls":{"copy":{}}},"source":"- (IBAction)clickButton:(id)sender {\n    [[TreasureData sharedInstance] addEventWithCallback:@{\n                       @\"name\": @\"boo bar\",\n                       @\"age\": @42,\n                       @\"comment\": @\"hello world\"\n                   }\n                   database:@\"testdb\"\n                      table:@\"demotbl\"\n                  onSuccess:^(){\n                      NSLog(@\"addEvent: success\");\n                  }\n                    onError:^(NSString* errorCode, NSString* message) {\n                        NSLog(@\"addEvent: error. errorCode=%@, message=%@\", errorCode, message);\n                    }];\n\n    // または、単純に...\n    //   [[TreasureData sharedInstance] addEvent:@{\n    //                     @\"name\": @\"boo bar\",\n    //                     @\"age\": @42,\n    //                     @\"comment\": @\"hello world\"\n    //                 }\n    //                 database:@\"testdb\"\n    //                    table:@\"demotbl\"];\n","lang":"objectivec"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["イベントをインポートするデータベースとテーブルを指定します。データベースとテーブルの合計長は129文字未満である必要があります。各テーブルは最大10000イベントをキャッシュします。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["さらに、イベント内のキーの長さは256文字を超えてはならず、イベント内の値の長さは10000文字を超えてはなりません。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"バッファされたイベントのtreasure-dataへのアップロード","__idx":14},"children":["バッファされたイベントのTreasure Dataへのアップロード"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["バッファされたイベントをTreasure Dataにアップロードするには、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TreasureData"]},"の",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["uploadEvents"]},"または",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["uploadEventsWithCallback"]}," APIを呼び出します。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"objective-c","header":{"controls":{"copy":{}}},"source":"- (void)applicationDidEnterBackground:(UIApplication *)application {\n\t__block UIBackgroundTaskIdentifier bgTask = [application beginBackgroundTaskWithExpirationHandler:^{\n\t\t[application endBackgroundTask:bgTask];\n\t\tbgTask = UIBackgroundTaskInvalid;\n\t}];\n\n    // バッファされたイベントをアップロードするために、いつでもこのAPIを呼び出すことができます。\n\t[[TreasureData sharedInstance] uploadEventsWithCallback:^() {\n\t\t\t[application endBackgroundTask:bgTask];\n\t\t\tbgTask = UIBackgroundTaskInvalid;\n\t\t}\n\t\tonError:^(NSString *code, NSString *msg) {\n\t\t\t[application endBackgroundTask:bgTask];\n\t\t\tbgTask = UIBackgroundTaskInvalid;\n\t\t}\n\t];\n\n    // または、単純に...\n    //  [[TreasureData sharedInstance] uploadEvents];\n","lang":"objective-c"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["バッファされたイベントをいつ、どのくらいの頻度でアップロードするかは、アプリケーションの特性によって異なります。Treasure Dataは、バッファされたイベントをアップロードする適切なタイミングとして、以下のウィンドウを推奨しています:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["現在の画面が閉じているとき、またはバックグラウンドに移動しているとき"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["アプリケーションを閉じるとき"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["送信されたイベントは、Treasure Dataストレージにインポートされる前に数分間バッファされます。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["tvOSでは、キャッシュストレージはいつでも削除される可能性のあるキャッシュディレクトリに保存されます。データの損失を防ぐため、イベントのアップロードAPIをできるだけ頻繁に呼び出すことを強くお勧めします。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"アップロードの再試行と重複排除","__idx":15},"children":["アップロードの再試行と重複排除"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["このSDKは、以下の機能の組み合わせと同じ方法でイベントをインポートします:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["SDKは、イベントがサーバー側に保存されたことの確認を受け取るまで、バッファされたイベントを保持します(少なくとも1回)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["サーバー側は、デフォルトで過去1時間以内のすべてのイベントの一意のキーを記憶し、重複したインポートを防ぎます(最大1回)。重複排除ウィンドウはデフォルトで1時間なので、重複したイベントを避けるために、バッファされたイベントをそれより長く保持しないでください。"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"デフォルト値","__idx":16},"children":["デフォルト値"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["テーブル、データベース、または任意のテーブルやデータベースに追加されたイベントに対して、キーの値を自動的に設定したい場合は、デフォルト値を設定します。同じキーに複数のデフォルト値が設定されている場合、新しく追加されたイベントには、以下の順序でデフォルト値が適用され、上書きされます:"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["すべてのテーブルとデータベースを対象とするデフォルト値が最初に適用されます。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["データベース内のすべてのテーブルを対象とするデフォルト値が次に適用されます。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["イベントが追加されるテーブルを対象とするデフォルト値が次に適用されます。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["イベントが追加されるテーブルとデータベースを対象とするデフォルト値が次に適用されます。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["最後に、イベントにそのキーの値がある場合、その値がすべてのデフォルト値を上書きします。"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["デフォルト値を設定するには:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"objectivec","header":{"controls":{"copy":{}}},"source":"[[TreasureData sharedInstance] setDefaultValue:@\"Value\" forKey:@\"key\" database:nil table:nil]; // すべてのデータベースとテーブルを対象\n[[TreasureData sharedInstance] setDefaultValue:@\"Value\" forKey:@\"key\" database:\"database_name\" table:nil]; // データベース\"database_name\"のすべてのテーブルを対象\n[[TreasureData sharedInstance] setDefaultValue:@\"Value\" forKey:@\"key\" database:nil table:\"table_name\"]; // \"table_name\"を持つすべてのテーブルを対象\n[[TreasureData sharedInstance] setDefaultValue:@\"Value\" forKey:@\"key\" database:\"database_name\" table:\"table_name\"]; // データベース\"database_name\"のテーブル\"table_name\"を対象\n","lang":"objectivec"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["デフォルト値を取得するには:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"objectivec","header":{"controls":{"copy":{}}},"source":"NSString *defaultValue = [[TreasureData sharedInstance] defaultValueForKey:@\"key\" database:\"database_name\" table:\"table_name\"]; // データベース\"database_name\"とテーブル\"table_name\"を対象とするキーのデフォルト値を取得\n","lang":"objectivec"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["デフォルト値を削除するには:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"objectivec","header":{"controls":{"copy":{}}},"source":"[[TreasureData sharedInstance] removeDefaultValueForKey:@\"key\" database:\"database_name\" table:\"table_name\"]; // データベース\"database_name\"とテーブル\"table_name\"を対象とするデフォルト値のみを削除\n","lang":"objectivec"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"セッションの開始と終了","__idx":17},"children":["セッションの開始と終了"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["startSession"]},"メソッドを呼び出すと、SDKは",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["endSession"]},"が呼び出されるまで保持されるセッションIDを生成します。セッションIDは、カラム名\"",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_session_id"]},"\"として出力されます。また、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["startSession"]},"および",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["endSession"]},"メソッドは、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["{\"td_session_event\":\"start\"または\"end\"}"]},"を含むイベントを追加します。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"objectivec","header":{"controls":{"copy":{}}},"source":"- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions\n{\n\t[TreasureData initializeWithApiKey:@\"YOUR_API_KEY\"];\n\t[[TreasureData sharedInstance] setDefaultDatabase:@\"testdb\"];\n\t[[TreasureData sharedInstance] startSession:@\"demotbl\"];\n}\n\n- (void)applicationDidEnterBackground:(UIApplication *)application\n{\n\t[[TreasureData sharedInstance] endSession:@\"demotbl\"];\n\n\t__block UIBackgroundTaskIdentifier bgTask = [application beginBackgroundTaskWithExpirationHandler:^{\n\t\t[application endBackgroundTask:bgTask];\n\t\tbgTask = UIBackgroundTaskInvalid;\n\t}];\n\n\t[[TreasureData sharedInstance] uploadEventsWithCallback:^() {\n\t\t\t[application endBackgroundTask:bgTask];\n\t\t\tbgTask = UIBackgroundTaskInvalid;\n\t\t}\n\t\tonError:^(NSString *code, NSString *msg) {\n\t\t\t[application endBackgroundTask:bgTask];\n\t\t\tbgTask = UIBackgroundTaskInvalid;\n\t\t}\n\t\t// 出力 =>>\n\t\t//   [{\"td_session_id\":\"cad88260-67b4-0242-1329-2650772a66b1\",\n\t\t//\t\t\"td_session_event\":\"start\", \"time\":1418880000},\n\t\t//\n\t\t//    {\"td_session_id\":\"cad88260-67b4-0242-1329-2650772a66b1\",\n\t\t//\t\t\"td_session_event\":\"end\", \"time\":1418880123}\n\t\t//    ]\n\t];\n","lang":"objectivec"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["以下のケースを処理したい場合は、グローバルセッショントラッキングのために、クラスメソッド",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["startSession"]},"と",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["endSession"]},"のペアを使用してください。"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["ユーザーがアプリケーションを開き、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["startSession"]},"を使用してセッショントラッキングを開始します。たとえば、これはセッション#0と呼ばれるかもしれません"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["ユーザーがホーム画面に移動し、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["endSession"]},"を使用してセッションを終了します"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["ユーザーがデフォルトの10秒以内にアプリケーションを再度開き、セッショントラッキングを再開します。ただし、この新しいセッションをセッション#0と同じセッションとして扱いたい場合"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"objectivec","header":{"controls":{"copy":{}}},"source":"- (void)applicationDidBecomeActive:(UIApplication *)application\n{\n\t[TreasureData startSession];\n}\n\n- (void)applicationDidEnterBackground:(UIApplication *)application\n{\n\t[TreasureData endSession];\n}\n","lang":"objectivec"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["この場合、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["getSessionId"]},"クラスメソッドを使用して現在のセッションIDを取得できます"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"objectivec","header":{"controls":{"copy":{}}},"source":"- (void)applicationDidBecomeActive:(UIApplication *)application\n{\n\t[TreasureData startSession];\n    NSLog(@\"Session ID=%@\", [TreasureData getSessionId]);\n}\n","lang":"objectivec"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"初回実行の検出","__idx":18},"children":["初回実行の検出"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["isFirstRun"]},"メソッドを使用して初回実行かどうかを検出し、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["clearFirstRun"]},"でフラグをクリアできます。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"objectivec","header":{"controls":{"copy":{}}},"source":"- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions\n\t\t:\n    if ([[TreasureData sharedInstance] isFirstRun]) {\n        [[TreasureData sharedInstance] addEventWithCallback:@{ @\"event\": @\"installed\" }\n                               database:@\"testdb\"\n                                  table:@\"demotbl\"\n                              onSuccess:^(){\n                                  [[TreasureData sharedInstance] uploadEventsWithCallback:^() {\n                                      [[TreasureData sharedInstance] clearFirstRun];\n                                    }\n                                    onError:^(NSString* errorCode, NSString* message) {\n                                      NSLog(@\"uploadEvents: error. errorCode=%@, message=%@\", errorCode, message);\n                                    }\n                                   ];\n                                }\n                                onError:^(NSString* errorCode, NSString* message) {\n                                    NSLog(@\"addEvent: error. errorCode=%@, message=%@\", errorCode, message);\n                                }];\n    }\n","lang":"objectivec"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"高度な使用方法","__idx":19},"children":["高度な使用方法"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"エラーコードについて","__idx":20},"children":["エラーコードについて"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["addEventWithCallback"]},"や",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["uploadEventWithCallback"]},"などのコールバック付き関数を使用する場合、これらのメソッドは",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["errorCode"]},"引数を使用して",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["onError"]},"ブロックを呼び出します。この引数は、エラーの原因や種類を判断するのに役立ちます。以下はエラーコードの一覧です。"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"エラーコード"},"children":["エラーコード"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"説明"},"children":["説明"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["init_error"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["初期化に失敗しました。"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["invalid_param"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["APIに渡されたパラメータが無効でした。"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["invalid_event"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["イベントが無効でした。"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["data_conversion"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["データのJSON変換に失敗しました。"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["storage_error"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["ストレージでのデータの読み書きに失敗しました。"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["network_error"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["ネットワークの問題によりサーバーとの通信に失敗しました。"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["server_response"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["サーバーがエラーレスポンスを返しました。"]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"追加設定","__idx":21},"children":["追加設定"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"エンドポイント","__idx":22},"children":["エンドポイント"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["デフォルトのAPIエンドポイント[ https://us01.records.in.treasuredata.com ]は変更できます。例:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"objectivec","header":{"controls":{"copy":{}}},"source":"[TreasureData initializeWithApiKey:@\"your_api_key\" apiEndpoint: @\"https://specifying-another-endpoint.com\"];\n","lang":"objectivec"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"暗号化キー","__idx":23},"children":["暗号化キー"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TreasureData.initializeEncryptionKey"]},"で暗号化キーを設定した場合、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TreasureData#addEvent"]},"または",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TreasureData.addEventWithCallback"]},"が呼び出されると、SDKはイベントデータを暗号化して保存します。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"objectivec","header":{"controls":{"copy":{}}},"source":"[TreasureData initializeEncryptionKey:@\"hello world\"];\n\n[[TreasureData sharedInstance] addEventWithCallback: ....];\n","lang":"objectivec"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"デフォルトデータベース","__idx":24},"children":["デフォルトデータベース"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["デフォルトデータベースを指定すると、以降の呼び出しでデータベース名の代わりに「@」記号を使用できます。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"objectivec","header":{"controls":{"copy":{}}},"source":"[[TreasureData sharedInstance] setDefaultDatabase:@\"testdb\"];\n\n[[TreasureData sharedInstance] addEventWithCallback:@{ @\"event\": @\"clicked\" } table:@\"demotbl\"]\n","lang":"objectivec"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"各イベントへのデバイスuuidの自動追加","__idx":25},"children":["各イベントへのデバイスUUIDの自動追加"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TreasureData#enableAutoAppendUniqId()"]},"を呼び出すと、各イベントにデバイスのUUIDが自動的に追加されます。この値は、アプリケーションがアンインストールされるまで変更されません。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"objectivec","header":{"controls":{"copy":{}}},"source":"[[TreasureData sharedInstance] enableAutoAppendUniqId];\n","lang":"objectivec"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["この値は",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_uuid"]},"という名前のカラムとして出力されます。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"uuidの取得とリセット","__idx":26},"children":["UUIDの取得とリセット"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["以下のAPIを使用して、現在のUUID(",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_uuid"]},")を取得できます。",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["resetUniqId"]},"が呼び出されると、このUUIDは変更されることに注意してください。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"objectivec","header":{"controls":{"copy":{}}},"source":"NSString *td_uuid = [[TreasureData sharedInstance] getUUID];\n","lang":"objectivec"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["以下のAPIを使用して、UUID(",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_uuid"]},")をリセットすることもできます。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"[[TreasureData sharedInstance] resetUniqId];\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"各イベントレコードへのuuidの自動追加","__idx":27},"children":["各イベントレコードへのUUIDの自動追加"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["enableAutoAppendRecordUUID"]},"を呼び出すと、各イベントレコードにUUIDが自動的に追加されます。各イベントは異なるUUIDを持ちます。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"objectivec","header":{"controls":{"copy":{}}},"source":"[[TreasureData sharedInstance] enableAutoAppendRecordUUID];\n\n// カラム名をカスタマイズする場合は、APIに渡します\n[[TreasureData sharedInstance] enableAutoAppendRecordUUID:@\"my_record_uuid\"];\n","lang":"objectivec"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["デフォルトでは、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["record_uuid"]},"というカラム名で値が出力されます。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"各イベントレコードへの広告idの自動追加","__idx":28},"children":["各イベントレコードへの広告IDの自動追加"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["enableAutoAppendAdvertisingIdentifier"]},"を呼び出すと、各イベントレコードに広告IDが自動的に追加されます。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["この機能を動作させるには、「Link Binary With Libraries」ビルドフェーズでAd Supportフレームワークをリンクする必要があります。また、ユーザーがiOSデバイスで「広告トラッキングの制限」機能をオンにしていない必要があります。オンになっている場合、Treasure Dataは広告ID(Ad Supportフレームワークから返される値)としてゼロで埋められた文字列を送信します。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["iOS 14以降では、AppTrackingTransparencyフレームワークを使用して、広告識別子の使用についてユーザーの明示的な許可を求める必要があります。この要件の実装方法については、AppleのAppTrackingTransparencyに関する公式ドキュメントを参照してください。この機能をオンにする場合、App Storeにアプリをレビュー用に提出する際に、広告識別子を取得する正当な理由を宣言する必要があることに注意してください。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"objectivec","header":{"controls":{"copy":{}}},"source":"[[TreasureData sharedInstance] enableAutoAppendAdvertisingIdentifier];\n\n// カラム名をカスタマイズする場合は、APIに渡します\n[[TreasureData sharedInstance] enableAutoAppendAdvertisingIdentifier:@\"custom_ad_id_column\"];\n","lang":"objectivec"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["デフォルトでは、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_maid"]},"というカラム名で値が出力されます。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"各イベントへのデバイスモデル情報の自動追加","__idx":29},"children":["各イベントへのデバイスモデル情報の自動追加"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TreasureData#enableAutoAppendModelInformation"]},"を呼び出すと、各イベントにデバイスモデル情報が自動的に追加されます。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"objectivec","header":{"controls":{"copy":{}}},"source":"[[TreasureData sharedInstance] enableAutoAppendModelInformation];\n","lang":"objectivec"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["以下のカラム名と値が出力されます。"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_device"]}," : UIDevice.model"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_model"]}," : UIDevice.model"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_os_ver"]}," : UIDevice.model.systemVersion"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_os_type"]}," : \"iOS\""]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"各イベントへのアプリケーションバージョン情報の自動追加","__idx":30},"children":["各イベントへのアプリケーションバージョン情報の自動追加"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["enableAutoAppendAppInformation"]},"を呼び出すと、各イベントにアプリケーションバージョン情報が自動的に追加されます。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"[[TreasureData sharedInstance] enableAutoAppendAppInformation];\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["以下のカラム名と値が出力されます。"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_app_ver"]}," : Core Foundationキー",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["CFBundleShortVersionString"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_app_ver_num"]}," : Core Foundationキー",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["CFBundleVersion"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"各イベントへのロケール設定情報の自動追加","__idx":31},"children":["各イベントへのロケール設定情報の自動追加"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TreasureData#enableAutoAppendLocaleInformation"]},"を呼び出すと、各イベントにロケール設定情報が自動的に追加されます。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"objectivec","header":{"controls":{"copy":{}}},"source":"[[TreasureData sharedInstance] enableAutoAppendLocaleInformation];\n","lang":"objectivec"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["以下のカラム名と値が出力されます。"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_locale_country"]}," : ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["[[NSLocale currentLocale] objectForKey: NSLocaleCountryCode]"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_locale_lang"]}," : ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["[[NSLocale currentLocale] objectForKey: NSLocaleLanguageCode]"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"デバイスipの自動トラッキング","__idx":32},"children":["デバイスIPの自動トラッキング"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["enableAutoTrackingIP"]},"を呼び出すと、各イベントに",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_ip"]},"カラムでデバイスIPが自動的に追加されます。トラッキングされるIPアドレスは、イベントを追加したときではなく、Treasure Dataにイベントをアップロードしたときのものであることに注意してください。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"[[TreasureData sharedInstance] enableAutoTrackingIP];\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["IPの自動トラッキングを無効にするには:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"[[TreasureData sharedInstance] disableAutoTrackingIP];\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"デバッグログの有効化と無効化","__idx":33},"children":["デバッグログの有効化と無効化"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"objectivec","header":{"controls":{"copy":{}}},"source":"[TreasureData enableLogging];\n","lang":"objectivec"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"objectivec","header":{"controls":{"copy":{}}},"source":"[TreasureData disableLogging];\n","lang":"objectivec"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"アプリライフサイクルイベントの自動トラッキング","__idx":34},"children":["アプリライフサイクルイベントの自動トラッキング"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["アプリライフサイクルイベントのトラッキングはオプションであり、デフォルトでは有効になっていません。",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["enableAppLifecycleEvent()"]},"を使用して、アプリライフサイクルイベントを自動的にトラッキングできます。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"[[TreasureData sharedInstance] enableAppLifecycleEvent];\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["トラッキングされるアプリライフサイクルイベントには3つのタイプがあります。"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TD_IOS_APP_OPEN"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TD_IOS_APP_INSTALL"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TD_IOS_APP_UPDATE"]},"(",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_ios_event"]},"カラムに書き込まれます)"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["以下は、トラッキングされたインストールイベントの例です。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"\"td_ios_event\" = \"TD_IOS_APP_INSTALL\";\n\"td_app_ver\" = \"1.1\";\n\"td_app_ver_num\" = 2;\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"アプリ内購入イベントの自動トラッキング","__idx":35},"children":["アプリ内購入イベントの自動トラッキング"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["アプリ内購入イベントのトラッキングはオプションであり、デフォルトでは有効になっていません。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Treasure Data SDKは、独自のトランザクションオブザーバーを記述することなく、IAP SKPaymentTransactionStatePurchasedイベントを自動的にトラッキングできます。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"objectivec","header":{"controls":{"copy":{}}},"source":"[[TreasureData sharedInstance] enableInAppPurchaseEvent];\n","lang":"objectivec"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["InAppPurchaseEvent、AppLifecycleEvent、customEventの間には微妙な違いがあります。後者の2つは永続的な設定であり、そのステータスはアプリの起動をまたいで保存されます。inAppPurchaseEventは通常のオブジェクトオプションのように動作し、保存されません。新しいTreasureDataインスタンス(initializeWithApiKey()を使用したsharedInstanceのみ)を初期化した後に有効にする必要があります。以下はIAPイベントの例です。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"- \"td_ios_event\" : \"TD_IOS_IN_APP_PURCHASE\",\n- \"td_iap_transaction_identifier\" : \"1000000514091400\",\n- \"td_iap_transaction_date\" : \"2019-03-28T08:44:12+07:00\",\n- \"td_iap_quantity\" : 1,\n- \"td_iap_product_identifier\" : \"com.yourcompany.yourapp.yourproduct\",\n- \"td_iap_product_price\" : 0.99,\n- \"td_iap_product_localized_title\" : \"Your Product Title\",\n- \"td_iap_product_localized_description\" : \"Your Product Description\",\n- \"td_iap_product_currency_code\" : \"USD\", // これはiOS 10以降でのみ利用可能です\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Treasure Dataは、製品に関する完全な情報を取得するために別のSKProductsRequestを実行します。リクエストが失敗した場合、",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td_iap_product_"]},"プレフィックスを持つフィールドはnullになります。",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["currency_code"]},"はiOS 10以降でのみ利用可能です。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"profiles-api","__idx":36},"children":["Profiles API"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["この機能はデフォルトではアカウントで有効になっていません。詳細については、カスタマーサポートまたはカスタマーサクセス担当者にお問い合わせください。"]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info","name":"info "},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["TreasureDataのsharedInstanceのcdpEndpointプロパティを設定する必要があります。"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["以下は、",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://docs.treasuredata.com/products/customer-data-platform/audience-studio/profiles"},"children":["Profiles API"]},"を使用してプロファイルを検索する方法の例です。"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"objectivec","header":{"controls":{"copy":{}}},"source":"// TreasureDataを初期化する際にcdpEndpointを設定します\n[[TreasureData sharedInstance] setCdpEnpoint: @\"[your cdp endpoint goes here]\"]\n\n// fetchUserSegmentsを呼び出して、ユーザーセグメントをNSArrayとして取得します\n\nNSArray *audienceTokens = @[@\"Your Profile API (Audience) Token here\"];\nNSDictionary *keys = @{@\"your_key\": @\"your_value\"};\nNSDictionary<TDRequestOptionsKey, id> *options = @{\n    TDRequestOptionsTimeoutIntervalKey: [NSNumber numberWithInteger: 10],\n    TDRequestOptionsCachePolicyKey: [NSNumber numberWithUnsignedInteger: NSURLRequestReloadIgnoringCacheData]\n};\n[[TreasureData sharedInstance] fetchUserSegments:audienceTokens\n                                            keys:keys\n                                        options:options\n                               completionHandler:^(NSArray * _Nullable jsonResponse, NSError * _Nullable error) {\n    NSLog(@\"fetchUserSegments jsonResponse: %@\", jsonResponse);\n    NSLog(@\"fetchUserSegments error: %@\", error);\n}];\n","lang":"objectivec"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"iosサポートバージョン","__idx":37},"children":["iOSサポートバージョン"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["サポートされているiOS/tvOSバージョンのリストについては、",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/treasure-data/td-ios-sdk?tab=readme-ov-file#supported-os-versions"},"children":["GitHubリポジトリ"]},"を参照してください。"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"参考資料","__idx":38},"children":["参考資料"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["追加情報については、",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/treasure-data/td-ios-sdk/blob/master/README.md#treasure-data-ios-sdk"},"children":["iOS SDK GitHub Repo"]},"を参照してください。"]}]},"headings":[{"value":"iOS SDK 1.2.1 クイックスタート","id":"ios-sdk-121-クイックスタート","depth":1},{"value":"前提条件と要件","id":"前提条件と要件","depth":2},{"value":"tvOS","id":"tvos","depth":2},{"value":"バージョン1.0.1への移行","id":"バージョン101への移行","depth":2},{"value":"Swiftでの使用","id":"swiftでの使用","depth":2},{"value":"インストール","id":"インストール","depth":3},{"value":"オプション1: CocoaPods","id":"オプション1-cocoapods","depth":3},{"value":"オプション2: Swift Package Manager","id":"オプション2-swift-package-manager","depth":3},{"value":"オプション3: Framework","id":"オプション3-framework","depth":3},{"value":"GDPR - 個人情報のトラッキング","id":"gdpr---個人情報のトラッキング","depth":2},{"value":"基本的な使用方法: Objective-C","id":"基本的な使用方法-objective-c","depth":2},{"value":"SDKヘッダーファイルのインポート","id":"sdkヘッダーファイルのインポート","depth":3},{"value":"Treasure APIキーの登録","id":"treasure-apiキーの登録","depth":3},{"value":"ローカルバッファへのイベントの追加","id":"ローカルバッファへのイベントの追加","depth":3},{"value":"バッファされたイベントのTreasure Dataへのアップロード","id":"バッファされたイベントのtreasure-dataへのアップロード","depth":3},{"value":"アップロードの再試行と重複排除","id":"アップロードの再試行と重複排除","depth":3},{"value":"デフォルト値","id":"デフォルト値","depth":3},{"value":"セッションの開始と終了","id":"セッションの開始と終了","depth":3},{"value":"初回実行の検出","id":"初回実行の検出","depth":3},{"value":"高度な使用方法","id":"高度な使用方法","depth":2},{"value":"エラーコードについて","id":"エラーコードについて","depth":3},{"value":"追加設定","id":"追加設定","depth":2},{"value":"エンドポイント","id":"エンドポイント","depth":3},{"value":"暗号化キー","id":"暗号化キー","depth":3},{"value":"デフォルトデータベース","id":"デフォルトデータベース","depth":3},{"value":"各イベントへのデバイスUUIDの自動追加","id":"各イベントへのデバイスuuidの自動追加","depth":3},{"value":"UUIDの取得とリセット","id":"uuidの取得とリセット","depth":3},{"value":"各イベントレコードへのUUIDの自動追加","id":"各イベントレコードへのuuidの自動追加","depth":3},{"value":"各イベントレコードへの広告IDの自動追加","id":"各イベントレコードへの広告idの自動追加","depth":3},{"value":"各イベントへのデバイスモデル情報の自動追加","id":"各イベントへのデバイスモデル情報の自動追加","depth":3},{"value":"各イベントへのアプリケーションバージョン情報の自動追加","id":"各イベントへのアプリケーションバージョン情報の自動追加","depth":3},{"value":"各イベントへのロケール設定情報の自動追加","id":"各イベントへのロケール設定情報の自動追加","depth":3},{"value":"デバイスIPの自動トラッキング","id":"デバイスipの自動トラッキング","depth":3},{"value":"デバッグログの有効化と無効化","id":"デバッグログの有効化と無効化","depth":3},{"value":"アプリライフサイクルイベントの自動トラッキング","id":"アプリライフサイクルイベントの自動トラッキング","depth":2},{"value":"アプリ内購入イベントの自動トラッキング","id":"アプリ内購入イベントの自動トラッキング","depth":2},{"value":"Profiles API","id":"profiles-api","depth":2},{"value":"iOSサポートバージョン","id":"iosサポートバージョン","depth":2},{"value":"参考資料","id":"参考資料","depth":2}],"frontmatter":{"seo":{"title":"Treasure Data iOS SDK クイックスタート"}},"lastModified":"2026-06-01T09:34:27.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/ja/products/customer-data-platform/integration-hub/streaming/mobile/ios","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}