BNotify icon
bnotify.com Console FAQ Contact JitPack
Platform · Android

Android SDK integration

Add BNotify to any Android app with JitPack, the Gradle config plugin, and a few lifecycle hooks. After setup, devices register automatically and can receive pushes plus in-app campaigns.

Create the app in Console first

Before Gradle setup, create a project, add an Android app, and download bnotify-config.json. Place that file at app/bnotify-config.json, then continue below.

Artifact bnotifysdk + bnotifyplugin Version 1.0.5 minSdk 24 Source GitHub

What you get after integration

CapabilityResult
Device registrationDevice appears in the BNotify dashboard after init
Push receiveSystem tray notifications
System notification UIShown automatically by the SDK (default)
Click / dismiss analyticsReported to BNotify
Token callbackOnTokenListener.onNewToken
In-app campaignsShown in-app when a campaign is due
Dashboard delivers campaigns

The Android SDK does not send notifications. Create and send campaigns from the BNotify dashboard. The SDK registers the device, displays messages, and reports engagement.

Prerequisites

RequirementNotes
Android Studio + Kotlin DSLExamples use .kts
minSdk ≥ 24Matches SDK
Internet on deviceRequired for registration and delivery
BNotify credentialsDownload bnotify-config.json after you register the Android app in Console
Config fieldsUse the values provided in the dashboard download
Physical deviceRecommended for notification testing

Integration checklist

  • 1Add JitPack to settings.gradle.kts
  • 2Add plugin classpath in project build.gradle.kts
  • 3implementation SDK + apply plugin in app module
  • 4Add app/bnotify-config.json (downloaded from Console)
  • 5Sync Gradle → confirm GeneratedConfig
  • 6Call BNotifyApp.initializeBase in Application
  • 7Register custom Application in manifest
  • 8handleIntent + token listener in launcher Activity
  • 9Subclass BNotifyMessagingService (recommended)
  • 10Handle screen extras for multi-screen routing

Step 1 — Repositories (settings.gradle.kts)

Add JitPack so Gradle can resolve the SDK and plugin. Merge into existing blocks if present.

Kotlin
pluginManagement {
    repositories {
        google {
            content {
                includeGroupByRegex("com\\.android.*")
                includeGroupByRegex("com\\.google.*")
                includeGroupByRegex("androidx.*")
            }
        }
        mavenCentral()
        gradlePluginPortal()
        maven { url = uri("https://jitpack.io") }
    }
}

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven { url = uri("https://jitpack.io") }
    }
}

Step 2 — Plugin classpath (project build.gradle.kts)

Kotlin
plugins {
    alias(libs.plugins.android.application) apply false
    alias(libs.plugins.kotlin.android) apply false
}

buildscript {
    repositories {
        maven(url = "https://jitpack.io")
    }
    dependencies {
        classpath("com.github.bnotify.bnotifysdk:bnotifyplugin:1.0.5")
    }
}
Coordinates

Library: com.github.bnotify.bnotifysdk:bnotifysdk:1.0.5
Plugin apply id: com.github.bnotifysdk.bnotifyplugin
Confirm on JitPack.

Step 3 — Dependency + plugin (app module)

Kotlin
plugins {
    alias(libs.plugins.android.application)
    alias(libs.plugins.kotlin.android)
}

android {
    namespace = "com.example.yourapp"
    compileSdk = 36
    defaultConfig {
        applicationId = "com.example.yourapp"
        minSdk = 24
        targetSdk = 36
    }
}

dependencies {
    implementation("com.github.bnotify.bnotifysdk:bnotifysdk:1.0.5")
}

apply(plugin = "com.github.bnotifysdk.bnotifyplugin")

On sync, the plugin reads app/bnotify-config.json and generates GeneratedConfig.kt under your applicationId package. Missing JSON fails the build with a clear error.

Step 4 — Add app/bnotify-config.json

Download this file from the Console after you register the Android app (see Create a project). Path required by the plugin: {projectRoot}/app/bnotify-config.json.

JSON
{
  "projectId": "your-project-id",
  "packageName": "com.example.yourapp",
  "apiKey": "your-api-key",
  "authDomain": "",
  "databaseURL": "",
  "storageBucket": "",
  "messagingSenderId": "",
  "appId": "your-app-id",
  "measurementId": "",
  "fcmAppId": "1:1234567890:android:abcdef",
  "fcmProjectId": "your-firebase-project-id",
  "fcmApiKey": "AIzaSy...",
  "fcmSenderId": "1234567890"
}
FieldRequiredUsed for
projectId, appId, apiKey, packageNameYesProject / app identity
fcmAppId, fcmProjectId, fcmApiKey, fcmSenderIdYesIncluded in the dashboard config file
Other fieldsOptionalReserved / future

Step 5 — Application class

Kotlin
class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        BNotifyApp.initializeBase(
            this,
            MainActivity::class.java,
            GeneratedConfig.JSON.toString()
        )
    }
}

Call this once in Application.onCreate. It registers the device, enables notifications, and starts in-app messaging. If your SDK version exposes a four-argument overload (app, context, activity, json), pass applicationContext as the second argument.

Step 6 — Manifest

XML
<application
    android:name=".MyApplication"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/Theme.YourApp">

    <activity
        android:name=".MainActivity"
        android:exported="true"
        android:launchMode="singleTop">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <service
        android:name=".MyNotificationService"
        android:exported="false" />
</application>
launchMode

Use singleTop or singleTask on the click Activity so onNewIntent runs when the app is already open.

Step 7 — MainActivity wiring

Kotlin
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    BNotifyApp.handleIntent(applicationContext, intent)

    BNotifyApp.setOnTokenListener(object : BNotifyApp.OnTokenListener {
        override fun onNewToken(token: String?) {
            Log.d("BNotify_Token", "BNotify Token: $token")
        }
    })

    intent.getStringExtra("screen")?.let { screen ->
        if (screen.equals("Test", true)) {
            BNotifyApp.setActivityToOpenOnClick(TestActivity::class.java)
            startActivity(Intent(this, TestActivity::class.java))
            finish()
        }
    }
}

override fun onNewIntent(intent: Intent) {
    super.onNewIntent(intent)
    setIntent(intent)
    BNotifyApp.handleIntent(applicationContext, intent)
}
CallWhy
handleIntentPermission path, click extras, service restart
setOnTokenListenerReceives the BNotify device token after registration
setActivityToOpenOnClickWhich Activity future taps should open
onNewIntentRequired when app is already in memory

Step 8 — Custom MessagingService

Kotlin
class MyNotificationService : BNotifyMessagingService() {
    override fun activityToOpenOnClick(): Class<out Activity> {
        return MainActivity::class.java
    }

    override fun onMessageReceived(remoteMessage: NotificationModel?) {
        Log.i("BNotify", "title: ${remoteMessage?.title}")
        // Custom UI when auto-notifications are disabled
    }
}

Notification permission (Android 13+)

The SDK declares POST_NOTIFICATIONS. For better UX, also request from your Activity:

Kotlin
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
    ActivityCompat.requestPermissions(
        this,
        arrayOf(Manifest.permission.POST_NOTIFICATIONS),
        1001
    )
}

Screen / deep routing

Send a screen field in the notification payload. The SDK places it in click Intent extras — your app decides navigation (home, Test, or any custom route).

In-app messaging

In-app campaigns appear inside the app (modal, card, top banner, fullscreen, and image). They can still show if the user denied system notification permission, as long as initializeBase has run and the device is online.

Verification

  1. Install on a physical device with network access.
  2. Confirm logs show the BNotify token callback.
  3. Send a test push from the BNotify dashboard.
  4. Tap the notification → Activity opens → click event tracked.
  5. Bring the app to the foreground and confirm an in-app campaign appears if one is scheduled.

Troubleshooting

SymptomLikely causeFix
Gradle cannot resolve artifactMissing JitPack repoAdd maven { url = uri("https://jitpack.io") } to both management blocks
No bnotify-config.jsonWrong pathFile must be app/bnotify-config.json
No tray notification on API 33+Permission deniedRequest POST_NOTIFICATIONS
Tap does nothing when app openMissing onNewIntentForward intent + use singleTop
No device on dashboardBad credentials / networkVerify the config JSON and that the device is online
Need help?

See the FAQ or contact support at bnotify93@gmail.com.