Skip to content
Documentation

Documentation

Unity

The package, the one Xcode step it saves you, and where the purchase link actually goes.

1. Add the package

json
"com.roassensor.unity-sdk": "https://github.com/rishabhrk2345/Roas-Unity-SDK.git?path=UnityPackage#v0.1.5"
Packages/manifest.json — copy the exact line from SDK integration in the panel; it pins the current version.

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 Asset in 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's Awake() runs. No code.
  • A direct call, if you need to control the moment yourself:
csharp
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 instead

The 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:

csharp
// 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 null

AppAccountToken() 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:

csharp
Roas.VerifyPurchase(transactionId: transactionId);                                            // iOS
Roas.VerifyPurchase(purchaseToken: purchaseToken, productId: productId, isSubscription: true);  // Android

Check it worked

  1. 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.
  2. The app's Testing tab shows an install row marked signed. unsigned means no app secret reached Initialize() — check the settings asset.
  3. Then Testing a mobile integration.