Android setup

Install com.invitebase:sdk, wire App Links, and understand Play Install Referrer attribution

com.invitebase:sdk is the native Kotlin SDK, distributed via Maven Central. It implements the shared surface with the two Android attribution paths: App Links for friends who already have your app, and the Play Install Referrer API for deferred attribution — deterministic, first-party, no prompt, near-100% match rate for Play Store installs.

This page covers what's specific to Android — installation, App Links, and the Install Referrer. The methods themselves are documented once for all platforms in the SDK reference. For a guided first integration, see the Android quickstart.

Install

app/build.gradle.kts
dependencies {
    implementation("com.invitebase:sdk:1.0.0")
}

The SDK bundles the com.android.installreferrer client, supports API 24+ (Android 7.0), and follows semver.

Configure at launch

Call configure once in Application.onCreate(). It generates (or restores) the anonymous ID from EncryptedSharedPreferences and — on first launch only — queries the Play Install Referrer for a referral code.

MycompanyApplication.kt
import android.app.Application
import com.invitebase.sdk.Invitebase

class MycompanyApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        Invitebase.configure(this, "pk_test_51Hq2jK")
    }
}

Register the Application class in your manifest:

AndroidManifest.xml
<application android:name=".MycompanyApplication" …>

App Links are the already-installed path: a friend taps https://mycompany.refr.link/a1b2c3, Android opens your app directly, and you hand the intent URI to handleInbound.

Invitebase serves /.well-known/assetlinks.json for your {app}.refr.link subdomain — you never host anything. Your steps:

  1. In the dashboard under Settings → Attribution, enter your package name and SHA-256 signing-certificate fingerprints.
  2. Add a verified intent filter to the activity that should receive links:
AndroidManifest.xml
<activity android:name=".MainActivity">
    <intent-filter android:autoVerify="true">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="https" android:host="mycompany.refr.link" />
    </intent-filter>
</activity>
  1. Hand incoming URIs to the SDK in both entry points:
MainActivity.kt
class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        Invitebase.handleInbound(intent?.data)
        // …
    }

    override fun onNewIntent(intent: Intent) {
        super.onNewIntent(intent)
        Invitebase.handleInbound(intent.data)
    }
}

Install Referrer notes

The Play Install Referrer is Android's deferred-attribution path, reported by resolveReferral: when an invitee without your app taps a referral link, the redirect sends them to the Play Store with referrer={code} on the URL; Google Play passes that string through the install, and on first launch the SDK recovers it via InstallReferrerClient — no prompt, no clipboard, deterministic.

  • One-shot: the SDK queries InstallReferrerClient once, on first launch, and never again after attribution resolves.
  • Play-Store-installs only: sideloads and other stores carry no referrer string — those installs resolve to needsManualEntry with a soft signal, and the manual code-entry fallback covers them.
  • Click and install-begin timestamps are captured alongside the code; they feed click-injection fraud detection.
  • No permissions and no user prompt are involved at any point.

Code entry UI

For the manual-entry fallback, the SDK ships a themeable InvitebaseCodeEntry composable with validation states and strong/soft prominence variants, fully replaceable with custom UI over applyCode.

Keep reward flows framed as a product benefit, not as payment for an install, review, or rating. Invitebase blocks cash-like rewards for the new Android user; use an offer code, free access, or an in-app reward instead. Grant anything valuable from your server via the signed reward webhook, and complete the Google Play referral compliance checklist before release.

Push notifications

If you use Invitebase-managed referral push notifications — the default delivery mode — forward the FCM registration token; Invitebase sends directly through FCM with the service-account key you upload in Settings:

MycompanyMessagingService.kt
class MycompanyMessagingService : FirebaseMessagingService() {
    override fun onNewToken(token: String) {
        Invitebase.setPushToken(token)
    }
}

onNewToken fires only when a token is generated or rotated, so also forward the current token once after configure:

FirebaseMessaging.getInstance().token.addOnSuccessListener { token ->
    Invitebase.setPushToken(token)
}

The SDK attaches the token to the current user — anonymous or identified. Details in setPushToken.

Bringing your own push provider instead? Skip this — device tokens stay on your side, and Invitebase will hand each notification to your backend as a notification.due webhook (bring-your-own-push is planned, not yet available).

What's next

On this page