Overview

FlockSDK-Android enables seamless integration of Flock referral and rewards into your Android applications. Effortlessly build powerful referral programs and track customer engagement in minutes.

  • Identify and track users
  • Present referral experiences as modals or full screen
  • Handle events (close, success, invalid) in-app
  • Officially supported by the Flock team

Requirements

  • Android 6.0 (API 23) or later
  • Kotlin 1.7 or later
  • Android Gradle Plugin 7.0 or later

Installation

  1. Add the SDK to your build.gradle dependencies:
implementation 'com.withflock:flocksdk:YOUR_VERSION'
  1. Replace YOUR_VERSION with the latest version from Jitpack.

Usage

1. Configure the SDK

Call FlockSDK.initialize once, ideally in your Application class or early in your app’s startup:

FlockSDK.initialize(
    publicAccessKey = "<YOUR_FLOCK_PUBLIC_KEY>",
    environment = FlockEnvironment.PRODUCTION // or FlockEnvironment.TEST
)

2. Identify Your User

Identify the current user (after login or at app start):

CoroutineScope(Dispatchers.Main).launch {
    FlockSDK.identify(
        externalUserId = "<USER_ID_IN_YOUR_APP>",
        email = "user@example.com",
        name = "Alice Smith"
    )
}

3. Show a Flock Page

New: Use addPlacement(context, placementId, ...) instead of openPage(context, type, ...) for opening campaign pages. Each campaign page now has a unique placementId for more robust and future-proof integration.

A placement renders a Flock referral page within your app, making it easy to prompt users to share and participate in your referral program.

FlockSDK.addPlacement(context, "my_placement_id", object : FlockWebViewCallback {
    override fun onClose() { /* ... */ }
    override fun onSuccess() { /* ... */ }
    override fun onInvalid() { /* ... */ }
})
  • The legacy openPage(context, type, ...) method is now deprecated and will be removed in a future release.
  • Use the Placement API for all new integrations and update any usage of openPage to addPlacement.

Legacy API (Deprecated)

Present the referral page anywhere in your app:

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 */ }
})

You can programmatically tell the Flock modal to navigate to a different page:

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.
  • Fully managed backend and analytics.
  • Easy integration and customization.
  • Official support and regular updates.

FAQ

Q: Is the SDK production-ready? A: Yes! FlockSDK is used in production by multiple apps and is actively maintained.

Q: Where can I get support? A: Reach out to support@withflock.com or visit our developer docs.

Q: Can I customize the UI? A: The SDK provides default modals, but you can control placement and trigger points in your app. For advanced customization, contact us.