Launch offer for the first 500 accounts: $10K MTR free for 24 months + $100 credit →
    .io
    Engagement
    Any platform
    Intermediate
    43 min

    Send push notifications and in-app messages

    To send push and in-app messages with BillDog, save your APNs key and FCM service account under Messaging → Settings → Push, pass the device token to BillDog.setDeviceToken (iOS) or declare BillDog's Firebase service (Android), and register the in-app messages module. Then compose the message under Messaging → Messages → Compose message, pick an audience and send.

    Steps last checked against the SDK source on 15 Nov 2026.

    What you'll build

    • APNs and FCM credentials saved and switched on in the dashboard
    • An iOS or Android app that registers its push token with BillDog
    • A test push delivered to your own device
    • An in-app message that shows when a user reaches a screen you choose

    What you'll need

    • An iOS or Android app with the BillDog SDK configured (iOS codelab, Android codelab). Web push doesn't send yet, so this codelab is mobile only
    • A real device: the iOS Simulator and emulators without Google Play services can't receive real push tokens
    • iOS: an Apple Developer account. Android: a Firebase project with your app added

    1. Save your APNs and FCM credentials

    8 min

    Get the credentials from Apple and Google first. Configure only the platforms you ship on.

    • APNs (iOS): in Apple Developer, open Certificates, Identifiers & Profiles → Keys, create a key with Apple Push Notifications service (APNs) enabled and its environment set to Sandbox & Production, download the .p8 file and note its Key ID. Your Team ID is in the Membership section.
    • FCM (Android): in the Firebase console, open Project Settings → Service Accounts and click Generate new private key. You get a JSON file. The old FCM server key no longer works.

    Then add them to BillDog:

    1. Open Engagement → Messaging, then Settings in the messaging sidebar, and stay on the Push tab.
    2. Turn on Enable Push Notifications. The FCM and APNs forms only appear once it is on.
    3. In Firebase Cloud Messaging (FCM HTTP v1), upload or paste the Service Account JSON, click Test credentials, then Save FCM Configuration.
    4. In Apple Push Notification service (APNs), fill in Bundle ID, Key ID, Team ID and .p8 Private Key Content (paste the whole file, including the BEGIN and END lines), then click Save APNs Configuration.

    The Configuration Status row at the top of the tab shows a badge for each platform. Use those badges, not the badge on the Push channel page.

    A key created for Sandbox & Production covers both Apple environments. BillDog sends to Apple's production host first and retries on the sandbox host when the token belongs to a development build, so a build you run from Xcode can receive pushes too. A Sandbox-only key reaches only builds run from Xcode, and a Production-only key only TestFlight and App Store builds.

    2. Register the device token on iOS

    8 min

    In Xcode, open your app target's Signing & Capabilities tab and add the Push Notifications capability. iOS hands the APNs token only to your app delegate, so add one to your SwiftUI app and pass the token to BillDog:

    MyApp.swift
    import SwiftUI
    import UIKit
    import BillDogFull
    
    final class AppDelegate: NSObject, UIApplicationDelegate {
        func application(_ application: UIApplication,
                         didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
            // Printed so you can paste it into the dashboard's test dialog
            print("APNs token: \(deviceToken.map { String(format: "%02x", $0) }.joined())")
            Task {
                do {
                    try await BillDog.shared.setDeviceToken(deviceToken)
                } catch {
                    print("Push token registration failed: \(error)")
                }
            }
        }
    
        func application(_ application: UIApplication,
                         didFailToRegisterForRemoteNotificationsWithError error: Error) {
            print("APNs registration failed: \(error)")
        }
    }
    
    @main
    struct MyApp: App {
        @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
    
        init() {
            BillDog.shared.configure(
                config: BillDogConfig(apiKey: "bd_public_test_YOUR_KEY", enableLogging: true)
            )
        }
    
        var body: some Scene {
            WindowGroup { ContentView() }
        }
    }

    Ask for permission at a moment that makes sense to the user, such as a button on a settings screen, and register for remote notifications only if they agree:

    ContentView.swift
    import SwiftUI
    import UIKit
    import UserNotifications
    
    struct ContentView: View {
        var body: some View {
            Button("Turn on notifications") {
                Task {
                    let center = UNUserNotificationCenter.current()
                    let granted = (try? await center.requestAuthorization(options: [.alert, .sound, .badge])) ?? false
                    if granted {
                        await MainActor.run {
                            UIApplication.shared.registerForRemoteNotifications()
                        }
                    }
                }
            }
        }
    }

    If you turned on consent checks with setConsentRequired(true), setDeviceToken throws until the user has given consent, and the device gets no pushes.

    3. Register the device token on Android

    8 min

    Add Firebase to your app first, following Firebase's Android setup guide: the google-services.json file, the com.google.gms.google-services Gradle plugin and firebase-messaging. Then add the BillDog modules:

    build.gradle.kts
    plugins {
        id("com.google.gms.google-services")
    }
    
    dependencies {
        implementation("io.billdog:billdog-notifications:1.2.0-beta.1")
        implementation("io.billdog:billdog-inappmessages:1.2.0-beta.1")
        implementation(platform("com.google.firebase:firebase-bom:YOUR_BOM_VERSION"))
        implementation("com.google.firebase:firebase-messaging")
    }

    Declare BillDog's ready-made Firebase service. It sends new tokens to BillDog and draws BillDog's pushes, which arrive as data messages:

    AndroidManifest.xml
    <application android:name=".MyApplication" ... >
        <service
            android:name="io.billdog.notifications.fcm.BillDogFirebaseMessagingService"
            android:exported="false">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>
    </application>

    Register the notifications module after configure. With Firebase in the app, it registers the current FCM token every time the app configures, so you write no token code:

    MyApplication.kt
    import android.app.Application
    import android.util.Log
    import com.google.firebase.messaging.FirebaseMessaging
    import io.billdog.core.BillDog
    import io.billdog.notifications.BillDogNotifications
    
    class MyApplication : Application() {
        override fun onCreate() {
            super.onCreate()
            BillDog.configure(this, "bd_public_test_YOUR_KEY")
            BillDog.use(BillDogNotifications(this))
    
            // Only for testing: print the token to paste into the dashboard's test dialog
            FirebaseMessaging.getInstance().token.addOnSuccessListener { token ->
                Log.d("FCM", "token: $token")
            }
        }
    }

    On Android 13 and later, ask for the POST_NOTIFICATIONS runtime permission, or notifications are not shown. The module already declares it in its manifest. If your app has its own FirebaseMessagingService, keep it and forward to BillDog: call BillDogFcm.register(applicationContext, token) from onNewToken, and BillDogMessagingService().onMessageReceived(applicationContext, message.data, message.notification?.title, message.notification?.body) from onMessageReceived. BillDog pushes are data messages, so without the forwarding they're never shown.

    4. Send a test push to your device

    4 min
    1. Run the app on your device, turn on notifications and copy the token from the Xcode console or Logcat.
    2. Put the app in the background. iOS doesn't show a banner for an app that is on screen unless the app handles it itself.
    3. In Messaging → Settings → Push, click Test Notifications.
    4. Choose the Platform, paste the Device Token, edit Notification Title and Notification Body, and click Send Test Notification.

    A Test notification sent message means Apple or Google accepted the push. If it fails, the error comes from Apple or Google: a wrong bundle ID, a key from another team, or a token copied incompletely are the usual causes.

    5. Turn on in-app messages

    5 min

    In-app messages need no credentials. Register the module once after configure, then ask for messages at the moment you want one to appear. Nothing shows until the app calls checkForMessages.

    Swift
    import BillDogFull
    
    // Once, right after BillDog.shared.configure(...)
    BillDog.shared.use(module: BillDogInAppMessagesManager.shared)
    
    // Where the message should appear, for example in a home screen's .onAppear
    BillDogInAppMessagesManager.shared.checkForMessages(trigger: "home_viewed")
    Kotlin
    import io.billdog.core.BillDog
    import io.billdog.inappmessages.BillDogInAppMessaging
    
    // Once, in your Application, after BillDog.configure(...)
    BillDog.use(BillDogInAppMessaging.shared)
    
    // Where the message should appear, for example in a home screen's onResume
    BillDogInAppMessaging.shared.checkForMessages("home_viewed")

    To hold messages back during a flow such as checkout, set paused = true on the same object, and set it back to false afterwards.

    6. Compose a message and choose the audience

    6 min

    Open Engagement → Messaging, click Messages in the messaging sidebar, then Compose message. Give it a Message Name (Internal) and pick a channel tab.

    • Push tab: fill in Title and Body. Action URL / Deep Link is optional and is passed to the app when the user taps. Use Platform Targeting to send to iOS (APNs), Android (FCM) or both.
    • In-App tab: choose a Display Type (modal, banner, bottom sheet or full screen), fill in Title and Body, add up to two buttons, then set Trigger to On Specific Event with Event Name home_viewed, the same name your app passes to checkForMessages. Or choose On App Open: the message shows at the next checkForMessages call, so call it when your app opens.

    Under Audience Targeting, choose one of:

    • Everyone: every subscriber the channel can reach. For push, that means customers who are opted in and have a registered device token, so a device that never called setDeviceToken is not counted.
    • Canonical audience rule: build a rule from segments, attributes, events, platform or subscription status.
    • One-off users: paste Subscriber IDs, useful for trying it on your own account first. These are BillDog's messaging subscriber IDs, not your app's user IDs. Find them under Messaging → Subscribers; the send icon on a row opens the composer with that subscriber already filled in.

    Under Delivery Schedule, keep Send Immediately and click Send Message. The draft is saved before it is sent, so what goes out is what's on screen. On the Push tab, Send Test at the top sends one copy to a device token you enter. On the In-App tab, Send Test queues one copy for the customer ID or app user ID you enter, shown the next time that user's app calls checkForMessages. Test sends don't fill in variables such as {{first_name}}.

    An in-app message marked sent is queued, not shown. It appears the next time that user's app calls checkForMessages with a matching trigger. Open the home screen on your device to see it.

    7. Check delivery and engagement

    4 min
    • Messaging → Messages → Sent lists your sends. Open one to see its Content, Targeting and Analytics tabs. If every recipient failed, the composer says Nothing was sent; open the message here to read the error for each recipient.
    • Messaging → Analytics summarizes all channels. For more detail, open Analytics, choose the Messaging Performance tab, then Push or In-App.
    • In-app impressions, button taps and dismissals are reported by the SDK as the message is shown and closed.

    For tap tracking, images and action buttons on iOS pushes, add BillDog's Notification Service Extension, described in the iOS guide. Next, see which users finished onboarding but didn't buy with a funnel, and target them with your next message.

    Frequently asked questions

    No, if you create the key for Sandbox & Production. That one .p8 key works for both: BillDog sends to Apple's production host first and retries on the sandbox host when the token belongs to a development build. A Sandbox-only key reaches only Xcode builds, and a Production-only key only TestFlight and App Store builds.

    Not yet. You can generate and save web push keys, but the send path skips web devices, so this codelab covers iOS and Android only.

    In-app messages are only fetched when the app calls checkForMessages, and the trigger name must match the event name set in the composer exactly. Also check that the module is registered after configure and that messages aren't paused in the app. Then check Messaging → Settings → In-App: Pause new in-app messages stops every message, and the default frequency cap (or the message's own cap) can hold one back. On the free plan, nothing shows once the project's in-app allowance is used up.

    A push audience only counts customers who are opted in and have a registered device token. Users who never granted permission, or whose app never passed its token to BillDog, can't be reached.

    Reference

    Ship it on a free project

    Create a project, grab your SDK key and follow along. Sandbox purchases and data stay separate from production, so test transactions never mix with real revenue.

    We use cookies and process your data to provide our services. By continuing, you agree to our Terms and Privacy Policy.