Skip to content

knocklabs/knock-android

Repository files navigation

Official Knock Android SDK

A client-side Kotlin library to integrate Knock into Android applications.

GitHub Release Jitpack compatible min Android SDK version GitHub license


Knock is a flexible, reliable notifications infrastructure that's built to scale with you. Use our Android SDK to engage users with in-app feeds, setup push notifications, and manage notification preferences.


Documentation

See the documentation for full documentation.

Migrations

See the Migration Guide if upgrading from a previous version.

Installation

1. Add Jitpack repository support in your settings.gradle file

pluginManagement {
    repositories {
        ..
        maven { url 'https://jitpack.io' }
    }
}

dependencyResolutionManagement {
    repositories {
        ..
        maven { url 'https://jitpack.io' }
    }
}

2. Add the implementation to your app build.gradle file

dependencies {
    implementation 'com.github.knocklabs:knock-android:<VERSION>'
}

3. Init the SDK and FeedManager

// Step 1: Early initialization. Ideal place: Application().onCreate() or MainActivity.
Knock.setup(context = "applicationContext", publishableKey = "your-pk", pushChannelId = "apns-channel-id")

// Step 2: Sign in the user. Ideal timing: as soon as you have the userId.
Knock.shared.signIn(userId = "userId", userToken = "userToken")