Skip to content

Commit e6abbbd

Browse files
authored
Merge pull request #741 from immutable/feat/sdk-305-mobile-attribution-flag
feat(audience-sdk): add EnableMobileAttribution + SKAdNetworkIds config (SDK-305)
2 parents 05d4190 + 32d8943 commit e6abbbd

3 files changed

Lines changed: 86 additions & 0 deletions

File tree

src/Packages/Audience/Runtime/AudienceConfig.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,40 @@ public class AudienceConfig
4949
/// </summary>
5050
public bool Debug { get; set; } = false;
5151

52+
/// <summary>
53+
/// Opts into mobile install-attribution signals (iOS ATT / IDFA /
54+
/// SKAdNetwork, Android Advertising ID / Install Referrer). Default
55+
/// <c>false</c>.
56+
/// </summary>
57+
/// <remarks>
58+
/// Two gates control attribution; both must be set for any data to
59+
/// ship:
60+
///
61+
/// 1. Build-time: add <c>AUDIENCE_MOBILE_ATTRIBUTION</c> to Player
62+
/// Settings → Other Settings → Scripting Define Symbols. Controls
63+
/// the AD_ID Android manifest permission, the iOS Privacy Manifest
64+
/// variant (<c>NSPrivacyTracking</c>), and whether native
65+
/// attribution code is compiled into the binary.
66+
///
67+
/// 2. Runtime: this flag. Controls whether attribution data is
68+
/// collected at runtime. Without the define, this setter is a
69+
/// no-op.
70+
///
71+
/// Studios who set neither ship a clean binary — no AD_ID permission,
72+
/// no native attribution code, <c>NSPrivacyTracking = false</c>.
73+
/// </remarks>
74+
public bool EnableMobileAttribution { get; set; } = false;
75+
76+
/// <summary>
77+
/// SKAdNetwork IDs the iOS post-processor injects into <c>Info.plist</c>
78+
/// at build time. Ignored on Android.
79+
/// </summary>
80+
/// <remarks>
81+
/// Read only when <see cref="EnableMobileAttribution"/> and the
82+
/// <c>AUDIENCE_MOBILE_ATTRIBUTION</c> scripting define are both set.
83+
/// </remarks>
84+
public string[]? SKAdNetworkIds { get; set; }
85+
5286
/// <summary>
5387
/// Interval between automatic flushes to the backend, in seconds.
5488
/// </summary>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#nullable enable
2+
3+
using NUnit.Framework;
4+
5+
namespace Immutable.Audience.Tests
6+
{
7+
[TestFixture]
8+
internal class AudienceConfigTests
9+
{
10+
[Test]
11+
public void EnableMobileAttribution_DefaultsToFalse()
12+
{
13+
// Default-off matters: a studio that never opts in must ship a
14+
// clean binary, no AD_ID permission, NSPrivacyTracking false.
15+
var config = new AudienceConfig();
16+
Assert.IsFalse(config.EnableMobileAttribution);
17+
}
18+
19+
[Test]
20+
public void SKAdNetworkIds_DefaultsToNull()
21+
{
22+
var config = new AudienceConfig();
23+
Assert.IsNull(config.SKAdNetworkIds);
24+
}
25+
26+
[Test]
27+
public void EnableMobileAttribution_RoundTrips()
28+
{
29+
var config = new AudienceConfig { EnableMobileAttribution = true };
30+
Assert.IsTrue(config.EnableMobileAttribution);
31+
}
32+
33+
[Test]
34+
public void SKAdNetworkIds_RoundTrips()
35+
{
36+
var ids = new[] { "abc123.skadnetwork", "def456.skadnetwork" };
37+
var config = new AudienceConfig { SKAdNetworkIds = ids };
38+
Assert.AreSame(ids, config.SKAdNetworkIds);
39+
}
40+
}
41+
}

src/Packages/Audience/Tests/Runtime/AudienceConfigTests.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)