Android SDK

Welcome to the Flock Android SDK! If you want to add a referral program to your app without building everything from scratch, you’re in the right place. We handle the UI, backend, and all the referral logic, so you can focus on your app.

🚀 Quick Start

1. Add Flock to Your Project

Add the SDK to your build.gradle dependencies:

implementation 'com.withflock:flocksdk:YOUR_VERSION'

Replace YOUR_VERSION with the latest version from Jitpack.

2. Initialize Flock

Call this early (usually in your Application class or main Activity):

FlockSDK.initialize(
    publicAccessKey = "YOUR_PUBLIC_KEY",
    environment = FlockEnvironment.PRODUCTION // or FlockEnvironment.TEST
)

3. Identify Your User

Let Flock know who’s using your app, so referrals are tracked correctly:

CoroutineScope(Dispatchers.Main).launch {
    FlockSDK.identify(
        externalUserId = "user-123",
        email = "user@email.com",
        name = "Jane Doe"
    )
}

4. Launch the Referral Flow

Show your users a full-screen referral experience with a single call:

FlockSDK.openPage(context, "referrer") // or "invitee" for invitees

React to Events

Want to know when users enter a code, hit an error, or close the modal? Just subscribe to events:

FlockSDK.openPage(context, "referrer", object : FlockWebViewCallback {
    override fun onClose() { /* User closed the modal */ }
    override fun onSuccess() { /* Invitee entered valid referral code */ }
    override fun onInvalid() { /* Invitee entered invalid referral code */ }
})

5. Control the Referral Flow

You can programmatically tell the Flock modal to navigate to a different page (if it’s open):

FlockSDK.navigate("invitee?state=success")

This is handy if you want to show the success screen after a user enters a valid code.


🛠️ Why Flock?

  • No UI to build – We handle the referral screens for you.
  • No backend to maintain – Flock manages referral logic, tracking, and rewards.
  • Production-ready – Full-screen, mobile-optimized, and easy to integrate.

🧩 Requirements

  • Android SDK 24+
  • Kotlin project

❓ FAQ

Q: What version of Android is supported? A: Android SDK 24 (Android 7.0) and up.

Q: Do I need to build any UI? A: Nope! Flock handles all the referral screens for you.

Q: Can I use this in a Java project? A: The SDK is written in Kotlin, but you can use it in Java projects with some interoperability work. We recommend Kotlin for the best experience.

Q: How do I test in a non-production environment? A: Use FlockEnvironment.TEST when initializing the SDK.

Q: Where do I find my public access key? A: You’ll get this from your Flock dashboard. If you’re not sure, reach out to us!

💬 Need Help?

Open an issue on GitHub or email us at support@withflock.com. We’re always happy to help!