### ByteBrew.InitializeByteBrew() Source: https://context7.com/bytebrewio/bytebrewunitysdk/llms.txt Initializes the ByteBrew SDK on game start. This method should be called once, typically in Awake() or Start(). It reads configuration from the ByteBrewSettings asset and has no effect in the Unity Editor. Returns immediately if already initialized. ```APIDOC ## InitializeByteBrew() ### Description Initializes the ByteBrew SDK on game start. Reads the `ByteBrewSettings` ScriptableObject from `Resources/` and starts the ByteBrew session. Must be called once, typically in `Awake()` or `Start()`. Has no effect in the Unity Editor. Returns immediately if already initialized. ### Method `ByteBrew.InitializeByteBrew()` ### Parameters None ### Request Example ```csharp using UnityEngine; using ByteBrewSDK; public class GameBootstrap : MonoBehaviour { void Start() { // Initialize ByteBrew — reads platform Game ID and SDK Key from ByteBrewSettings asset ByteBrew.InitializeByteBrew(); // Confirm initialization completed (native library ready) if (ByteBrew.IsByteBrewInitialized()) { Debug.Log("ByteBrew is ready. User ID: " + ByteBrew.GetUserID()); } } } ``` ``` -------------------------------- ### Initialize ByteBrew SDK Source: https://context7.com/bytebrewio/bytebrewunitysdk/llms.txt Call this once in Awake() or Start() to initialize the SDK. It reads settings from the ByteBrewSettings asset and has no effect in the Unity Editor. Check initialization status with IsByteBrewInitialized(). ```csharp using UnityEngine; using ByteBrewSDK; public class GameBootstrap : MonoBehaviour { void Start() { // Initialize ByteBrew — reads platform Game ID and SDK Key from ByteBrewSettings asset ByteBrew.InitializeByteBrew(); // Confirm initialization completed (native library ready) if (ByteBrew.IsByteBrewInitialized()) { Debug.Log("ByteBrew is ready. User ID: " + ByteBrew.GetUserID()); } } } ``` -------------------------------- ### Load and Show Rewarded Cross-Promo Ads Source: https://context7.com/bytebrewio/bytebrewunitysdk/llms.txt Load and display a rewarded cross-promo ad. The `OnRewardedAdRewarded` event is crucial for granting in-game rewards upon successful completion. This method also supports `ctrlOnly` targeting. The example includes logic to reload the ad after dismissal and a button handler to show the ad if it's ready. ```csharp using UnityEngine; using ByteBrewSDK; public class RewardedAdManager : MonoBehaviour { private const string AdUnitID = "your_rewarded_unit_id"; void Start() { ByteBrewAds.OnRewardedAdLoaded += data => Debug.Log("Rewarded ad ready"); ByteBrewAds.OnRewardedAdLoadError += (err, d) => Debug.LogWarning("Rewarded load error: " + err); ByteBrewAds.OnRewardedAdRewarded += data => GrantReward(); ByteBrewAds.OnRewardedAdDismissed += data => ReloadAd(); ReloadAd(); } private void ReloadAd() => ByteBrewAds.LoadRewardedCrossPromoAd(AdUnitID); public void OnShowRewardedButtonPressed() { if (ByteBrewAds.IsCrossPromoAdLoaded(AdUnitID) && !ByteBrewAds.IsAdShowing()) { ByteBrewAds.ShowRewardedCrossPromoAd(AdUnitID); } else { Debug.Log("Rewarded ad not ready yet"); } } private void GrantReward() { Debug.Log("Reward granted!"); // Add coins, extra life, etc. } } ``` -------------------------------- ### Load and Show Interstitial Cross-Promo Ads Source: https://context7.com/bytebrewio/bytebrewunitysdk/llms.txt Load an interstitial ad by its unit ID and display it. You can optionally restrict delivery to CTRL AI-targeted impressions. Subscribe to ad load and lifecycle events for detailed control. The example includes logic to load the next ad upon completion or dismissal. ```csharp using UnityEngine; using ByteBrewSDK; public class InterstitialAdManager : MonoBehaviour { private const string AdUnitID = "your_interstitial_unit_id"; void Start() { ByteBrewAds.OnInterstitialAdLoaded += data => Debug.Log("Interstitial loaded: " + data); ByteBrewAds.OnInterstitialAdLoadError += (err, data) => Debug.LogWarning("Load error: " + err); ByteBrewAds.OnInterstitialAdCompleted += data => LoadNextAd(); ByteBrewAds.OnInterstitialAdDismissed += data => LoadNextAd(); LoadNextAd(); } private void LoadNextAd() { ByteBrewAds.LoadInterstitialCrossPromoAd(AdUnitID); // CTRL-only targeting: ByteBrewAds.LoadInterstitialCrossPromoAd(AdUnitID, ctrlOnly: true); } public void ShowAd() { if (ByteBrewAds.IsAdsInitialized() && !ByteBrewAds.IsAdShowing()) { ByteBrewAds.ShowInterstitialCrossPromoAd(AdUnitID); } } } ``` -------------------------------- ### Initialize ByteBrew Ads Subsystem Source: https://context7.com/bytebrewio/bytebrewunitysdk/llms.txt Call this method to bootstrap ByteBrew's ad network. Subscribe to success and failure events before initialization to handle the outcome. This method has no effect in the Unity Editor. ```csharp using UnityEngine; using ByteBrewSDK; public class AdsBootstrap : MonoBehaviour { void Start() { ByteBrewAds.OnAdsInitSuccess += () => Debug.Log("ByteBrew Ads ready"); ByteBrewAds.OnAdsInitFailure += () => Debug.LogError("ByteBrew Ads failed to initialize"); ByteBrewAds.InitializeAds(); } } ``` -------------------------------- ### ByteBrew.IsByteBrewInitialized() Source: https://context7.com/bytebrewio/bytebrewunitysdk/llms.txt Checks if the native SDK library is fully ready. Returns true once the underlying native library (Android/iOS/WebGL) has finished initializing. Use this before sending events if you need a strict readiness guarantee. ```APIDOC ## IsByteBrewInitialized() ### Description Checks if the native SDK library is fully ready. Returns `true` once the underlying native library (Android/iOS/WebGL) has finished initializing. On WebGL this also checks the JavaScript bridge. Use this before sending events if you need a strict readiness guarantee. ### Method `ByteBrew.IsByteBrewInitialized()` ### Parameters None ### Response - **bool**: `true` if the SDK is initialized, `false` otherwise. ### Request Example ```csharp using UnityEngine; using ByteBrewSDK; public class SafeEventSender : MonoBehaviour { void Update() { if (ByteBrew.IsByteBrewInitialized() && Input.GetButtonDown("Fire1")) { ByteBrew.NewCustomEvent("playerShot"); } } } ``` ``` -------------------------------- ### Register for Push Notifications Source: https://context7.com/bytebrewio/bytebrewunitysdk/llms.txt Call `StartPushNotifications` after `InitializeByteBrew` to register the device. This is supported on Android and iOS. Retrieve the user ID using `GetUserID` to target specific users from your backend. ```csharp using UnityEngine; using ByteBrewSDK; public class NotificationSetup : MonoBehaviour { void Start() { ByteBrew.InitializeByteBrew(); ByteBrew.StartPushNotifications(); // Store the ByteBrew user ID to map to your own user records string byteBrewUserID = ByteBrew.GetUserID(); Debug.Log("ByteBrew User ID: " + byteBrewUserID); // Send byteBrewUserID to your server for targeting specific users } } ``` -------------------------------- ### Initialize Ads Source: https://context7.com/bytebrewio/bytebrewunitysdk/llms.txt Initializes the ByteBrew Ads subsystem, enabling the AI-powered cross-promo ad network. It's recommended to subscribe to initialization success and failure events before calling this method. This method has no effect in the Unity Editor. ```APIDOC ## InitializeAds ### Description Initializes the ByteBrew Ads subsystem, enabling the AI-powered cross-promo ad network (CTRL behavioral targeting engine) on Android and iOS. Subscribe to `OnAdsInitSuccess` and `OnAdsInitFailure` before calling to handle results. No-op in the Unity Editor. ### Method `ByteBrewAds.InitializeAds()` ### Parameters None ### Request Example ```csharp using ByteBrewSDK; // Subscribe to events before initialization ByteBrewAds.OnAdsInitSuccess += () => Debug.Log("ByteBrew Ads ready"); ByteBrewAds.OnAdsInitFailure += () => Debug.LogError("ByteBrew Ads failed to initialize"); // Initialize Ads ByteBrewAds.InitializeAds(); ``` ### Response None directly, but events `OnAdsInitSuccess` and `OnAdsInitFailure` are triggered. ``` -------------------------------- ### Check ByteBrew Initialization State Source: https://context7.com/bytebrewio/bytebrewunitysdk/llms.txt Use this to ensure the native SDK library is ready before sending events. It checks the underlying native library on Android/iOS/WebGL and the JavaScript bridge on WebGL. ```csharp using UnityEngine; using ByteBrewSDK; public class SafeEventSender : MonoBehaviour { void Update() { if (ByteBrew.IsByteBrewInitialized() && Input.GetButtonDown("Fire1")) { ByteBrew.NewCustomEvent("playerShot"); } } } ``` -------------------------------- ### Validate In-App Purchases with Callback Source: https://context7.com/bytebrewio/bytebrewunitysdk/llms.txt Submit a purchase receipt to ByteBrew's backend for real-time validation and receive a callback with the validation result. Use this to gate in-game reward delivery on confirmed purchases. ```csharp using UnityEngine; using ByteBrewSDK; public class SecureIAPManager : MonoBehaviour { public void ValidateApplePurchase(string receipt) { ByteBrew.ValidateiOSInAppPurchaseEvent( store: "Apple App Store", currency: "USD", amount: 9.99f, itemID: "noAdsBundle", category: "Bundles", receipt: receipt, purchaseResultData: OnPurchaseValidated ); } public void ValidateGooglePurchase(string receipt, string signature) { ByteBrew.ValidateGoogleInAppPurchaseEvent( store: "Google Play Store", currency: "USD", amount: 9.99f, itemID: "noAdsBundle", category: "Bundles", receipt: receipt, signature: signature, purchaseResultData: OnPurchaseValidated ); } private void OnPurchaseValidated(ByteBrewPurchaseData result) { // result.isValid — true if receipt is legitimate // result.purchaseProcessed — true if ByteBrew servers processed it // result.message — human-readable status explanation // result.itemID — echoed item ID // result.platform — "iOS" or "Android" // result.timestamp — server verification time if (result.isValid && result.purchaseProcessed) { Debug.Log($"Purchase verified for {result.itemID} on {result.platform} at {result.timestamp}"); UnlockNoAds(); } else { Debug.LogWarning($"Purchase invalid: {result.message}"); } } private void UnlockNoAds() { /* grant entitlement */ } } ``` -------------------------------- ### GDPR/CCPA Tracking Consent Controls Source: https://context7.com/bytebrewio/bytebrewunitysdk/llms.txt Implement `StopTracking` to immediately halt data collection, useful for opt-outs or pre-initialization blocking. Use `RestartTracking` followed by `InitializeByteBrew` to resume tracking after consent is granted. ```csharp using UnityEngine; using ByteBrewSDK; public class ConsentManager : MonoBehaviour { public void OnUserDeclinedTracking() { // Stops all data collection immediately, even before initialization ByteBrew.StopTracking(); } public void OnUserGrantedTracking() { // Re-enable tracking then reinitialize the session ByteBrew.RestartTracking(); ByteBrew.InitializeByteBrew(); } } ``` -------------------------------- ### Fetch and Read Remote Configuration Values Source: https://context7.com/bytebrewio/bytebrewunitysdk/llms.txt Use `RemoteConfigsUpdated` to fetch configurations and `GetRemoteConfigForKey` to read specific values. Call `HasRemoteConfigsBeenSet` to avoid redundant fetches if configs are cached. ```csharp using UnityEngine; using ByteBrewSDK; public class RemoteConfigManager : MonoBehaviour { private float _enemyHealth = 100f; private string _welcomeMessage = "Welcome!"; void Start() { ByteBrew.InitializeByteBrew(); // Skip re-fetching if configs are already cached if (ByteBrew.HasRemoteConfigsBeenSet()) { ApplyConfigs(); } else { ByteBrew.RemoteConfigsUpdated(OnConfigsReady); } } private void OnConfigsReady() { ApplyConfigs(); } private void ApplyConfigs() { // Returns remote value or falls back to default string rawHealth = ByteBrew.GetRemoteConfigForKey("enemy_health", "100"); _enemyHealth = float.Parse(rawHealth); _welcomeMessage = ByteBrew.GetRemoteConfigForKey("welcome_message", "Welcome!"); string shopRotation = ByteBrew.GetRemoteConfigForKey("daily_shop_item", "sword"); Debug.Log($"Config loaded — enemy health: {_enemyHealth}, shop item: {shopRotation}"); } } ``` -------------------------------- ### Push Notifications Source: https://context7.com/bytebrewio/bytebrewunitysdk/llms.txt Register the device for push notifications using ByteBrew.StartPushNotifications(). This function is available on Android and iOS and should be called after InitializeByteBrew(). ```APIDOC ## Push Notifications ### `ByteBrew.StartPushNotifications()` — Register the device for push notifications Registers the device with ByteBrew's push notification service. Works on Android and iOS only (no-op on WebGL and Editor). Call after `InitializeByteBrew()`. Combine with `GetUserID()` to target specific users from your backend. ```csharp using UnityEngine; using ByteBrewSDK; public class NotificationSetup : MonoBehaviour { void Start() { ByteBrew.InitializeByteBrew(); ByteBrew.StartPushNotifications(); // Store the ByteBrew user ID to map to your own user records string byteBrewUserID = ByteBrew.GetUserID(); Debug.Log("ByteBrew User ID: " + byteBrewUserID); // Send byteBrewUserID to your server for targeting specific users } } ``` ``` -------------------------------- ### Track In-App Purchase Events Source: https://context7.com/bytebrewio/bytebrewunitysdk/llms.txt Record an in-app purchase event to ByteBrew. Use platform-specific variants to submit receipts for server-side validation. ```csharp using UnityEngine; using ByteBrewSDK; public class IAPManager : MonoBehaviour { // Called after a successful Apple purchase public void OnApplePurchaseSuccess(string receiptData) { // Basic tracking (no receipt validation) ByteBrew.TrackInAppPurchaseEvent("Apple App Store", "USD", 4.99f, "gemPack_100", "Currency"); // With receipt — triggers server-side validation ByteBrew.TrackiOSInAppPurchaseEvent("Apple App Store", "USD", 4.99f, "gemPack_100", "Currency", receiptData); } // Called after a successful Google Play purchase public void OnGooglePurchaseSuccess(string receipt, string signature) { ByteBrew.TrackGoogleInAppPurchaseEvent("Google Play Store", "USD", 4.99f, "gemPack_100", "Currency", receipt, signature); } } ``` -------------------------------- ### Remote Configurations Source: https://context7.com/bytebrewio/bytebrewunitysdk/llms.txt Fetch and read remote configuration values using ByteBrew.RemoteConfigsUpdated and ByteBrew.GetRemoteConfigForKey. Use ByteBrew.HasRemoteConfigsBeenSet to check if configurations are cached locally. ```APIDOC ## Remote Configurations ### `ByteBrew.RemoteConfigsUpdated(Action)` / `ByteBrew.GetRemoteConfigForKey(string, string)` — Fetch and read remote configuration values `RemoteConfigsUpdated` triggers a network fetch and fires the callback once values are available. `GetRemoteConfigForKey` retrieves a string value by key, returning a default if the key doesn't exist. `HasRemoteConfigsBeenSet()` lets you skip the fetch if configs are already cached locally. ```csharp using UnityEngine; using ByteBrewSDK; public class RemoteConfigManager : MonoBehaviour { private float _enemyHealth = 100f; private string _welcomeMessage = "Welcome!"; void Start() { ByteBrew.InitializeByteBrew(); // Skip re-fetching if configs are already cached if (ByteBrew.HasRemoteConfigsBeenSet()) { ApplyConfigs(); } else { ByteBrew.RemoteConfigsUpdated(OnConfigsReady); } } private void OnConfigsReady() { ApplyConfigs(); } private void ApplyConfigs() { // Returns remote value or falls back to default string rawHealth = ByteBrew.GetRemoteConfigForKey("enemy_health", "100"); _enemyHealth = float.Parse(rawHealth); _welcomeMessage = ByteBrew.GetRemoteConfigForKey("welcome_message", "Welcome!"); string shopRotation = ByteBrew.GetRemoteConfigForKey("daily_shop_item", "sword"); Debug.Log($"Config loaded — enemy health: {_enemyHealth}, shop item: {shopRotation}"); } } ``` ``` -------------------------------- ### ByteBrew.NewCustomEvent(...) Source: https://context7.com/bytebrewio/bytebrewunitysdk/llms.txt Tracks a named game event with optional parameters. This method can be used to send custom analytics events to ByteBrew, with support for no extra data, a single string or float value, or a dictionary of string parameters for rich segmentation. ```APIDOC ## NewCustomEvent(...) ### Description Tracks a named game event with optional parameters. Sends a custom analytics event to ByteBrew. Overloaded to accept no extra data, a single string value, a single float value, or a full `Dictionary` of sub-parameters for rich segmentation on the dashboard. ### Method `ByteBrew.NewCustomEvent(string eventName)` `ByteBrew.NewCustomEvent(string eventName, string value)` `ByteBrew.NewCustomEvent(string eventName, float value)` `ByteBrew.NewCustomEvent(string eventName, Dictionary parameters)` ### Parameters - **eventName** (string) - Required - The name of the custom event. - **value** (string or float) - Optional - A single value associated with the event. - **parameters** (Dictionary) - Optional - A dictionary of key-value pairs for detailed event segmentation. ### Request Example ```csharp using System.Collections.Generic; using UnityEngine; using ByteBrewSDK; public class AnalyticsManager : MonoBehaviour { public void OnLevelStart(int levelNumber) { // Simple event ByteBrew.NewCustomEvent("levelStarted"); // Event with a string value ByteBrew.NewCustomEvent("weaponEquipped", "SledgeHammer"); // Event with a numeric value ByteBrew.NewCustomEvent("coinsCollected", 350f); // Event with multiple sub-parameters (recommended for best dashboard insight) var parameters = new Dictionary { { "level", levelNumber.ToString() }, { "difficulty", "hard" }, { "character", "warrior" } }; ByteBrew.NewCustomEvent("levelStarted", parameters); } public void OnLevelFail(int levelNumber, int attemptsLeft) { var parameters = new Dictionary { { "level", levelNumber.ToString() }, { "attemptsLeft", attemptsLeft.ToString() } }; ByteBrew.NewCustomEvent("levelFailed", parameters); } } ``` ``` -------------------------------- ### Track Custom Events with Parameters Source: https://context7.com/bytebrewio/bytebrewunitysdk/llms.txt Send custom analytics events to ByteBrew. Supports events with no data, a single string/float value, or a Dictionary for multiple sub-parameters for detailed segmentation. ```csharp using System.Collections.Generic; using UnityEngine; using ByteBrewSDK; public class AnalyticsManager : MonoBehaviour { public void OnLevelStart(int levelNumber) { // Simple event ByteBrew.NewCustomEvent("levelStarted"); // Event with a string value ByteBrew.NewCustomEvent("weaponEquipped", "SledgeHammer"); // Event with a numeric value ByteBrew.NewCustomEvent("coinsCollected", 350f); // Event with multiple sub-parameters (recommended for best dashboard insight) var parameters = new Dictionary { { "level", levelNumber.ToString() }, { "difficulty", "hard" }, { "character", "warrior" } }; ByteBrew.NewCustomEvent("levelStarted", parameters); } public void OnLevelFail(int levelNumber, int attemptsLeft) { var parameters = new Dictionary { { "level", levelNumber.ToString() }, { "attemptsLeft", attemptsLeft.ToString() } }; ByteBrew.NewCustomEvent("levelFailed", parameters); } } ``` -------------------------------- ### App Tracking Transparency (iOS) Source: https://context7.com/bytebrewio/bytebrewunitysdk/llms.txt Request iOS App Tracking Transparency consent using ByteBrew.requestForAppTrackingTransparency. The callback provides the system status code to determine whether to initialize tracking. ```APIDOC ## App Tracking Transparency (iOS) ### `ByteBrew.requestForAppTrackingTransparency(Action)` — Request iOS ATT consent and handle the result Presents the iOS App Tracking Transparency prompt and invokes the callback with the system status code: `0` = Not Determined, `1` = Restricted, `2` = Denied, `3` = Authorized. Use the result to decide whether to initialize tracking. iOS only. ```csharp using UnityEngine; using ByteBrewSDK; public class PrivacyManager : MonoBehaviour { void Start() { #if UNITY_IPHONE ByteBrew.requestForAppTrackingTransparency(OnATTResult); #else // Non-iOS: initialize directly ByteBrew.InitializeByteBrew(); #endif } #if UNITY_IPHONE private void OnATTResult(int status) { // 0 = Not Determined, 1 = Restricted, 2 = Denied, 3 = Authorized Debug.Log("ATT Status: " + status); if (status == 3) { // User authorized tracking ByteBrew.InitializeByteBrew(); } else { // User denied — stop tracking entirely or restart after re-prompt ByteBrew.StopTracking(); } } #endif } ``` ``` -------------------------------- ### Tracking Consent Controls Source: https://context7.com/bytebrewio/bytebrewunitysdk/llms.txt Control tracking consent for GDPR/CCPA compliance using ByteBrew.StopTracking() and ByteBrew.RestartTracking(). StopTracking() halts all event dispatch, while RestartTracking() re-enables it. ```APIDOC ## Tracking Consent Controls ### `ByteBrew.StopTracking()` / `ByteBrew.RestartTracking()` — GDPR / CCPA opt-out and opt-in controls `StopTracking()` immediately halts all event dispatch and can be called before initialization to prevent any tracking. `RestartTracking()` re-enables tracking; follow it with `InitializeByteBrew()` to resume a full session after a user grants consent. ```csharp using UnityEngine; using ByteBrewSDK; public class ConsentManager : MonoBehaviour { public void OnUserDeclinedTracking() { // Stops all data collection immediately, even before initialization ByteBrew.StopTracking(); } public void OnUserGrantedTracking() { // Re-enable tracking then reinitialize the session ByteBrew.RestartTracking(); ByteBrew.InitializeByteBrew(); } } ``` ``` -------------------------------- ### ValidateiOSInAppPurchaseEvent / ValidateGoogleInAppPurchaseEvent Source: https://context7.com/bytebrewio/bytebrewunitysdk/llms.txt Validates a purchase with ByteBrew's backend and returns a callback with validation results. Use this to gate in-game reward delivery on confirmed purchases. ```APIDOC ## ByteBrew.ValidateiOSInAppPurchaseEvent(...) / ByteBrew.ValidateGoogleInAppPurchaseEvent(...) ### Description Submits a purchase receipt to ByteBrew's backend for real-time validation and returns a `ByteBrewPurchaseData` callback containing `isValid`, `purchaseProcessed`, `message`, `itemID`, `platform`, and `timestamp`. Use this to gate in-game reward delivery on confirmed purchases. ### Method Signature `ValidateiOSInAppPurchaseEvent(string store, string currency, float amount, string itemID, string category, string receipt, System.Action purchaseResultData)` `ValidateGoogleInAppPurchaseEvent(string store, string currency, float amount, string itemID, string category, string receipt, string signature, System.Action purchaseResultData)` ### Callback Data Structure (`ByteBrewPurchaseData`) - **isValid** (bool) - true if receipt is legitimate - **purchaseProcessed** (bool) - true if ByteBrew servers processed it - **message** (string) - human-readable status explanation - **itemID** (string) - echoed item ID - **platform** (string) - "iOS" or "Android" - **timestamp** (string) - server verification time ``` -------------------------------- ### ByteBrew.SetCustomUserDataAttribute(string key, T value) Source: https://context7.com/bytebrewio/bytebrewunitysdk/llms.txt Tags users with key-value attributes for segmentation. This method attaches arbitrary attributes to the current user profile on the ByteBrew backend, supporting string, int, double, and bool value types for player segmentation and analysis. ```APIDOC ## SetCustomUserDataAttribute(string key, T value) ### Description Tags users with key-value attributes for segmentation. Attaches arbitrary attributes to the current user profile on the ByteBrew backend. Supports `string`, `int`, `double`, and `bool` value types. Use these for player segmentation, cohort analysis, and custom filtering on the dashboard. ### Method `ByteBrew.SetCustomUserDataAttribute(string key, T value)` ### Parameters - **key** (string) - Required - The key for the user data attribute. - **value** (T) - Required - The value of the user data attribute. Supports `string`, `int`, `double`, and `bool`. ### Request Example ```csharp using UnityEngine; using ByteBrewSDK; public class UserProfileManager : MonoBehaviour { public void OnPlayerProfileUpdated(string playerName, int playerLevel, double totalSpend, bool isPremium) { ByteBrew.SetCustomUserDataAttribute("playerName", playerName); // string ByteBrew.SetCustomUserDataAttribute("playerLevel", playerLevel); // int ByteBrew.SetCustomUserDataAttribute("totalSpend", totalSpend); // double ByteBrew.SetCustomUserDataAttribute("isPremium", isPremium); // bool } } ``` ``` -------------------------------- ### Load and Show Interstitial Cross-Promo Ads Source: https://context7.com/bytebrewio/bytebrewunitysdk/llms.txt Loads a cross-promo interstitial ad by its ad unit ID and then displays it once it has been successfully loaded. The `ctrlOnly` parameter can be used to restrict ad delivery to CTRL AI-targeted impressions only. Event listeners for ad loading and lifecycle events are crucial for managing the ad flow. ```APIDOC ## LoadInterstitialCrossPromoAd / ShowInterstitialCrossPromoAd ### Description Loads a cross-promo interstitial by ad unit ID, then shows it once loaded. The optional `ctrlOnly` boolean restricts delivery to CTRL AI-targeted impressions only. Subscribe to load and lifecycle events for full control. ### Method `ByteBrewAds.LoadInterstitialCrossPromoAd(string adUnitId, bool ctrlOnly = false)` `ByteBrewAds.ShowInterstitialCrossPromoAd(string adUnitId)` ### Parameters #### Path Parameters - **adUnitId** (string) - Required - The unique identifier for the ad unit. - **ctrlOnly** (bool) - Optional - If true, restricts delivery to CTRL AI-targeted impressions only. ### Request Example ```csharp using ByteBrewSDK; // Subscribe to events ByteBrewAds.OnInterstitialAdLoaded += data => Debug.Log("Interstitial loaded: " + data); ByteBrewAds.OnInterstitialAdLoadError += (err, data) => Debug.LogWarning("Load error: " + err); ByteBrewAds.OnInterstitialAdCompleted += data => LoadNextAd(); ByteBrewAds.OnInterstitialAdDismissed += data => LoadNextAd(); // Load an ad ByteBrewAds.LoadInterstitialCrossPromoAd("your_interstitial_unit_id"); // For CTRL-only targeting: // ByteBrewAds.LoadInterstitialCrossPromoAd("your_interstitial_unit_id", ctrlOnly: true); // Show the ad (ensure it's loaded and no other ad is showing) if (ByteBrewAds.IsAdsInitialized() && !ByteBrewAds.IsAdShowing()) { ByteBrewAds.ShowInterstitialCrossPromoAd("your_interstitial_unit_id"); } ``` ### Response None directly, but events like `OnInterstitialAdLoaded`, `OnInterstitialAdLoadError`, `OnInterstitialAdCompleted`, and `OnInterstitialAdDismissed` are triggered. ``` -------------------------------- ### Request iOS App Tracking Transparency (ATT) Consent Source: https://context7.com/bytebrewio/bytebrewunitysdk/llms.txt Use `requestForAppTrackingTransparency` on iOS to prompt the user for ATT consent. The callback provides a status code indicating the user's choice. Initialize tracking only if authorized. ```csharp using UnityEngine; using ByteBrewSDK; public class PrivacyManager : MonoBehaviour { void Start() { #if UNITY_IPHONE ByteBrew.requestForAppTrackingTransparency(OnATTResult); #else // Non-iOS: initialize directly ByteBrew.InitializeByteBrew(); #endif } #if UNITY_IPHONE private void OnATTResult(int status) { // 0 = Not Determined, 1 = Restricted, 2 = Denied, 3 = Authorized Debug.Log("ATT Status: " + status); if (status == 3) { // User authorized tracking ByteBrew.InitializeByteBrew(); } else { // User denied — stop tracking entirely or restart after re-prompt ByteBrew.StopTracking(); } } #endif } ``` -------------------------------- ### Track Ad Impression Events Source: https://context7.com/bytebrewio/bytebrewunitysdk/llms.txt Record ad impressions with revenue, including ad type, provider, unit name, and revenue. An optional location string can be provided for placement-level reporting. ```csharp using UnityEngine; using ByteBrewSDK; public class AdRevenueTracker : MonoBehaviour { // Call this from your ad network's impression callback public void OnAdImpression(string adUnitID, double revenue) { // Rewarded ad — with location ByteBrew.TrackAdEvent( adType: ByteBrewAdTypes.Reward, adProvider: "IronSource", adUnitName: adUnitID, adLocation: "levelComplete", revenue: revenue ); } public void OnInterstitialShown(string adUnitID, double revenue) { // Interstitial — without explicit location ByteBrew.TrackAdEvent( adType: ByteBrewAdTypes.Interstitial, adProvider: "AdMob", adUnitName: adUnitID, revenue: revenue ); } public void OnBannerImpression(string adUnitID, double revenue) { ByteBrew.TrackAdEvent(ByteBrewAdTypes.Banner, "AdMob", adUnitID, revenue); } } ``` -------------------------------- ### Load and Show Rewarded Cross-Promo Ads Source: https://context7.com/bytebrewio/bytebrewunitysdk/llms.txt Loads and displays a rewarded cross-promo ad. The `OnRewardedAdRewarded` event is the primary callback for granting in-game rewards upon successful ad completion. This method also supports the `ctrlOnly` targeting mode. ```APIDOC ## LoadRewardedCrossPromoAd / ShowRewardedCrossPromoAd ### Description Loads and shows a rewarded cross-promo ad unit. `OnRewardedAdRewarded` is the canonical event to grant in-game rewards — only fires on successful completion. Also supports `ctrlOnly` targeting mode. ### Method `ByteBrewAds.LoadRewardedCrossPromoAd(string adUnitId, bool ctrlOnly = false)` `ByteBrewAds.ShowRewardedCrossPromoAd(string adUnitId)` ### Parameters #### Path Parameters - **adUnitId** (string) - Required - The unique identifier for the ad unit. - **ctrlOnly** (bool) - Optional - If true, restricts delivery to CTRL AI-targeted impressions only. ### Request Example ```csharp using ByteBrewSDK; // Subscribe to events ByteBrewAds.OnRewardedAdLoaded += data => Debug.Log("Rewarded ad ready"); ByteBrewAds.OnRewardedAdLoadError += (err, d) => Debug.LogWarning("Rewarded load error: " + err); ByteBrewAds.OnRewardedAdRewarded += data => GrantReward(); ByteBrewAds.OnRewardedAdDismissed += data => ReloadAd(); // Load an ad ByteBrewAds.LoadRewardedCrossPromoAd("your_rewarded_unit_id"); // For CTRL-only targeting: // ByteBrewAds.LoadRewardedCrossPromoAd("your_rewarded_unit_id", ctrlOnly: true); // Show the ad (ensure it's loaded and no other ad is showing) if (ByteBrewAds.IsCrossPromoAdLoaded("your_rewarded_unit_id") && !ByteBrewAds.IsAdShowing()) { ByteBrewAds.ShowRewardedCrossPromoAd("your_rewarded_unit_id"); } // Function to grant reward private void GrantReward() { Debug.Log("Reward granted!"); // Add coins, extra life, etc. } ``` ### Response None directly, but events like `OnRewardedAdLoaded`, `OnRewardedAdLoadError`, `OnRewardedAdRewarded`, and `OnRewardedAdDismissed` are triggered. ``` -------------------------------- ### Set Custom User Data Attributes Source: https://context7.com/bytebrewio/bytebrewunitysdk/llms.txt Tag users with key-value attributes for segmentation and filtering on the dashboard. Supports string, int, double, and bool value types. ```csharp using UnityEngine; using ByteBrewSDK; public class UserProfileManager : MonoBehaviour { public void OnPlayerProfileUpdated(string playerName, int playerLevel, double totalSpend, bool isPremium) { ByteBrew.SetCustomUserDataAttribute("playerName", playerName); // string ByteBrew.SetCustomUserDataAttribute("playerLevel", playerLevel); // int ByteBrew.SetCustomUserDataAttribute("totalSpend", totalSpend); // double ByteBrew.SetCustomUserDataAttribute("isPremium", isPremium); // bool } } ``` -------------------------------- ### TrackAdEvent Source: https://context7.com/bytebrewio/bytebrewunitysdk/llms.txt Tracks ad impressions, including revenue. Supports different ad types and provides optional placement-level reporting. ```APIDOC ## ByteBrew.TrackAdEvent(ByteBrewAdTypes, string, string, double) ### Description Records an ad impression including the ad type (`Interstitial`, `Reward`, or `Banner`), provider name, ad unit name, and revenue value. The latest overload also accepts an optional `adLocation` string for placement-level reporting. ### Method Signature `TrackAdEvent(ByteBrewAdTypes adType, string adProvider, string adUnitName, double revenue)` `TrackAdEvent(ByteBrewAdTypes adType, string adProvider, string adUnitName, string adLocation, double revenue)` ### Parameters #### Enum `ByteBrewAdTypes` - `Interstitial` - `Reward` - `Banner` ``` -------------------------------- ### TrackInAppPurchaseEvent Source: https://context7.com/bytebrewio/bytebrewunitysdk/llms.txt Records an in-app purchase event for monetization analytics. Use platform-specific variants to submit receipts for server-side validation. ```APIDOC ## ByteBrew.TrackInAppPurchaseEvent(...) ### Description Sends a purchase event to ByteBrew with store, currency, amount, item ID, and category. Use the platform-specific variants (`TrackiOSInAppPurchaseEvent`, `TrackGoogleInAppPurchaseEvent`) to also submit receipts for server-side validation. ### Method Signature `TrackInAppPurchaseEvent(string store, string currency, float amount, string itemID, string category)` `TrackiOSInAppPurchaseEvent(string store, string currency, float amount, string itemID, string category, string receiptData)` `TrackGoogleInAppPurchaseEvent(string store, string currency, float amount, string itemID, string category, string receipt, string signature)` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.