Appstock for Unity
  • Documentation
  • API Reference
Search Results for

    Show / Hide Table of Contents
    • Overview
    • Package Contents
    • Installation
    • Requirements and limitations
      • Requirements
      • Unity 2021/2022 Android issues
      • iOS blocks insecure requests
      • iOS Simulator on arm64
    • Displaying Ads
      • SDK Initialization
      • Banner Ad
      • Interstitial Ad
      • Rewarded Ad
      • Native Ads
        • Introduction to Native Ads
        • Building Native Ad Request
        • Applying Native Ad Response
    • Advanced Configuration
      • SDK Configuration
      • Improving targeting
      • Ext Slot
    • Samples

    SDK Configuration

    ISdkProxy provides few global configuration options.

    Sdk property of Appstock can be used to get the instance of ISdkProxy.

    Warning

    ISdkProxy::ExternalUserIds and SdkConfig::externalUserIds expose a potentially-deprecated property of native SDK library.

    ITargetingProxy::ExternalUserIds / TargetingData::externalUserIds should be used instead in most cases.

    See Improving targeting / External User IDs.

    Data-driven approach

    SdkConfig is a data container -- with a SerializableAttribute -- for specifying settings via Unity Editor.

    sdk-config-in-inspector

    Applying the config

    • Expose SdkConfig variable on your MonoBehaviour
      • Or put it inside some ScriptableObject and assign through that.
    • Call extension method Apply(ISdkProxy, SdkConfig) on Appstock.Sdk and pass your SdkConfig.
    #nullable enable
    
    namespace AppstockSDK.DevApp
    {
        public class TargetingDemo : MonoBehaviour
        {
            public SdkConfig sdkConfig = new();
            public TargetingData targetingData = new();
            
            // Start is called before the first frame update
            private IEnumerator Start()
            {
                Debug.Log($"[{DateTime.Now:O}] Applying config...");
                Appstock.Sdk.Apply(sdkConfig);
    
    Tip

    You can find a complete code in "ConfigAndTargeting" sample.

    Taking a config snapshot

    SdkConfigSnapshot can retrieve all readable properties from ISdkProxy.

    var sdkConfigSnapshot = new SdkConfigSnapshot(Appstock.Sdk);
    

    It can be serialized and logged into console

    var snapshotJson = JsonUtility.ToJson(sdkConfigSnapshot, prettyPrint: true);
    Debug.Log($"(snapshot) {snapshotJson}");
    

    or compared to the expected config -- to log differences for later manual inspection.

    var unequalFields = sdkConfigSnapshot.UnequalFields(sdkConfig).ToList(); 
    if (unequalFields.Any())
    {
        var configJson = JsonUtility.ToJson(sdkConfig, prettyPrint: true);
        Debug.Log($"(config) {configJson}");
        Debug.LogWarning($"[DIFF-FIELDS] ({unequalFields.Count}): {string.Join(", ", unequalFields)}.");
    }
    else
    {
        Debug.Log("SDK config applied successfully.");
    }
    
    In this article
    Back to top Generated by DocFX