Documentation
Unity
The package, the one Xcode step it saves you, and where the purchase link actually goes.
1. Add the package
"com.roassensor.unity-sdk": "https://github.com/rishabhrk2345/Roas-Unity-SDK.git?path=UnityPackage#v0.1.5"No Gradle line and no Podfile line: unlike the Flutter plugin and the React Native bridge, the Unity package links its own iOS frameworks (AdSupport, AppTrackingTransparency, AdServices, StoreKit) automatically on every build, through a postprocess step that runs as part of Unity's own iOS export. There is nothing to add in Xcode afterward.
On Android, the advertising id, App Set Id and Play Install Referrer need their Play Services libraries resolved into the build — the package declares them, but resolving them needs External Dependency Manager for Unity installed in your project. Without it those three signals read as absent rather than failing the build; every call is guarded.
2. Initialize
Two ways to start it, and most integrations only need the first:
- The settings asset —
ROASSensor → Create Settings Assetin the Unity menu, paste the public key (and the app secret, if you sign beacons) for each platform you ship, leave Auto Initialize on, and the SDK starts itself before any scene'sAwake()runs. No code. - A direct call, if you need to control the moment yourself:
Roas.Initialize(
publicKey: "IOS_OR_ANDROID_PUBLIC_KEY",
baseUrl: "https://api.roassensor.com", // from the panel
appSecret: "YOUR_SIGNING_SECRET"); // optional -- or leave it on the settings asset insteadThe parameter order is frozen — appSecret stays last, mirroring the Kotlin and Swift SDKs exactly, since a Unity game is as likely as a native app to have a build script binding these positionally.
App Tracking Transparency is a settings-asset field too (Request Tracking Authorization On Launch, on by default), not a call argument — turn it off there and call Roas.RequestTrackingAuthorization() yourself after onboarding if a cold-start system prompt is the wrong moment for your game. iOS also needs NSUserTrackingUsageDescription added under Player Settings → iOS → Other Settings; Unity will not add it for you, and the prompt has nothing to show without it.
3. Bind purchases to the install
The store gives you one field for a buyer identifier; put ours in it. Unity has no first-party purchase API in scope here — Unity IAP and third-party plugins vary in whether, and how, they let you set that field on the purchase request itself, so this page names the SDK's own two calls rather than one specific plugin's method that might not match yours:
// iOS -- whatever your plugin calls it (often applicationUserName or appAccountToken)
var token = Roas.AppAccountToken(); // a UUID, or null before Initialize()
// Android -- Play Billing's obfuscated account id
var accountId = Roas.ObfuscatedAccountId(); // the visitor id unchanged, or nullAppAccountToken() is a UUID derived from the visitor id, not a separate identifier — the server reconstructs the vid from it. ObfuscatedAccountId() is the visitor id verbatim; Play accepts any string up to 64 characters, so nothing needs converting. Skip either and the sale still records, it just arrives with nothing tying it to an ad click.
Once your plugin confirms the purchase, report it immediately instead of waiting on the store's own notification:
Roas.VerifyPurchase(transactionId: transactionId); // iOS
Roas.VerifyPurchase(purchaseToken: purchaseToken, productId: productId, isSubscription: true); // Android4. Deep links and the rest
Unity delivers a deep link two ways, and both need forwarding or a tap on an already-installed build never attributes:
// Warm open
Application.deepLinkActivated += url => Roas.HandleDeepLink(url);
// Cold start -- Application.absoluteURL is already set by the time Awake() runs
if (!string.IsNullOrEmpty(Application.absoluteURL)) Roas.HandleDeepLink(Application.absoluteURL);
Roas.Identify(email: user.Email); // hashed on device
Roas.Track(RoasEvent.BeginCheckout, properties: new Dictionary<string, object> {
{ RoasProps.ProductId, productId },
});
Roas.SetLogLevel(RoasLogLevel.Debug); // logcat / Xcode consoleRoasProps.ProductId must equal the store product id so the funnel and the sale line up. Events are never revenue.
Check it worked
- Run once on a device — the Simulator and most emulators skip the advertising-id and install-referrer reads entirely, so a real device is what the Testing tab actually needs. The console shows
first-open -> HTTP 201. - The app's Testing tab shows an install row marked
signed.unsignedmeans no app secret reachedInitialize()— check the settings asset. - Then Testing a mobile integration.