Getting started with the Android SDK

Get started with the Knock Android SDK to build in-app notification experiences.

To get started, you will need the following:

  • A Knock Account
  • A public API key for the Knock environment (which you'll use in the publishableKey)
  • An in-app feed channel with a workflow that produces in-app feed messages (optional)
  • An APNS channel with a workflow that produces push notifications (optional)

Installation

You can install the Android SDK in a the following ways:

  • Jitpack
  • Manually

See here for more information on installation.

Initializing a Knock instance

To initialize the shared Knock instance, you are required to use your publishable key, which is identified by the prefix pk_. Additionally, if you opt to utilize our KnockMessagingService and KnockActivity for comprehensive device token registration and management, you must also include your pushChannelId during the setup process of your instance.

You should do this setup as soon as you can. Preferrably within your Application class.

Authenticating a user

Once you've configured the shared Knock instance with your publishable key, the next step is to sign the user into Knock. This requires the userId and, for interactions with your production Knock environment, the userToken. For further details on userTokens, please refer to our documentation.

We recommend you initiate the user sign-in process at the earliest point where the userId is known to you. This ensures that your application is ready to leverage Knock's features with the context of the signed-in user.