Before you begin
- Delivery — Delivery must be enabled in your workspace.
- Parent model — Delivery must have a parent model selected in the Data source card on Delivery > Settings > Profiles. Push notifications are addressed to users by its primary key.
- Firebase project — Your app must be registered in a Firebase project, and you need access to its Project settings to create a service account key.
- Test device — Use a device or an emulator with Google Play services.
- Android 5.0 or later — The SDK supports API level 21 and later.
Collect your Firebase credentials
Hightouch sends notifications through Firebase Cloud Messaging (FCM) on your behalf, using two values from your Firebase project.
The service account key is a private credential. Upload it to Hightouch and don’t commit it to your app’s repository.
Create an Android event source
The SDK sends device registrations and notification opens to a Hightouch event source of type Android. Skip this section if your workspace already has one.- Go to Event Collection > Event sources and click Create source.
- Click Android and finish creating the source.
- On the source’s Setup tab, copy the Write key and the API Host.
Register your app in Hightouch
- Go to Delivery > Settings > Apps. If you already registered this app for iOS, open it and skip to the next step. Otherwise, click Add, enter a Name, and click Add. The name appears on every notification.
- On the Android (FCM) card, click Enable.
- Enter your Firebase credentials, then save.
- Copy the App ID from the top of the Android (FCM) card.
The App ID isn’t your app’s package name or bundle ID. It’s an ID that Hightouch assigns.
Configure your Android project
Add Firebase to your app
If your app doesn’t use Firebase yet, follow Add Firebase to your Android project: downloadgoogle-services.json into your app module and apply the Google Services Gradle plugin. The Hightouch SDK includes Firebase Cloud Messaging, so you don’t need to add it separately.
Install the SDK
The SDK is published on JitPack. Add the JitPack repository insettings.gradle.kts:
build.gradle.kts:
Set a notification icon
Android needs a small icon to display a notification. Declare one inAndroidManifest.xml, inside <application>:
Declare the notification permission
Android 13 and later require thePOST_NOTIFICATIONS permission to show notifications. Add it to AndroidManifest.xml, outside <application>:
Initialize the SDK
InitializeHightouchPush in your Application class’s onCreate with your write key, API host, and App ID. Android can start your app in the background to deliver a push, so initializing here makes sure the SDK is ready.
YOUR_API_HOST with the API Host from your event source’s Setup tab, such as eu-west-1.hightouch-events.com, and keep /v1 at the end.
If you already create an Analytics instance to track events, pass that one to HightouchPush.initialize instead of creating a second. Its write key must belong to your Android event source.
The SDK registers the device with FCM on its own. You don’t need to fetch or forward the token.
HightouchPushConfig.Builder takes these options:
Request notification permission
On Android 13 and later, ask the user for permission before you expect notifications to show. You decide when to ask; many apps wait until after onboarding. This example requests it from an activity:Identify users on login and logout
Callidentify when a user logs in and logout when they log out:
identify links the device to that user, and logout unlinks it so the device stops receiving their notifications.
If you also track events with the Android SDK, call HightouchPush.identify instead of analytics.identify so the device stays linked to the right user.
Handle notification taps
The SDK handles taps on its own. It records the open, follows the notification’s link, and opens your app when there’s no link. To read a notification’s custom data in the activity it opens, callHightouchPush.getCustomData(intent) in onCreate or onNewIntent.
Handle deep links
By default, the SDK openshttps links with Android’s standard link handling, which uses your app’s App Links when they match. To route links yourself, set a URL handler and return true for links you handle:
myapp://, add the scheme to setAllowedProtocols. Keep the handler fast, since it runs on the main thread.
Use the SDK alongside another FCM provider
If your app already has its ownFirebaseMessagingService, Android delivers messages to yours instead of the SDK’s. Forward new tokens and messages to the SDK:
handleMessageReceived returns false for messages that didn’t come from Hightouch.
Choose a notification channel
Android groups notifications into channels that users can turn on and off in system settings. By default, Hightouch pushes use a channel named “Push notifications” that the SDK creates for you. To use your own channel, create it in your app, then pass its ID tosetNotificationChannelId. A channel’s sound and importance come from the channel, not from the campaign.
Receive silent pushes
A silent push delivers custom data to your app without showing a notification. Set a listener on your config:Send yourself a test push
Run your app on a device and log in so thatidentify runs, then send a test from Hightouch. In both places, Validate checks that a device is registered for the user ID you enter.
From app settings: Go to Delivery > Settings > Apps, open your app, and click Test. Enter your user ID, click Validate, then click Send test. The test includes an image, so it also checks that rich notifications display.
From the campaign editor: Go to Delivery > Campaigns, click Add campaign, and select Push. In the Create a new campaign dialog, select your app under Choose apps to target, choose a brand if asked, and click Continue. Under Content, click Edit and write your message. On the Preview tab, click Send test, enter your user ID, click Validate, then click Send test.
If Validate finds no device, you can enter a device token instead. A test that arrives this way means your push credentials work and the device isn’t linked to that user.
Troubleshooting
No active devices found
Validate shows this when no device is registered for the user ID. Check that:appIdis the App ID from your app’s Android (FCM) card.- Your app calls
identifyafter the user logs in, with the parent model’s primary key. - The API host in your SDK setup matches the API Host on your Android event source’s Setup tab.
identify again on the device. To see what your app sends, open your Android event source’s Debugger tab. After identify, you see a CEP Push Token Events event with your user ID and an app_id that matches your App ID.
If your app has its own FirebaseMessagingService, also check that it forwards tokens to the SDK.
Validate passes, but no notification appears
Check that the user granted notification permission on Android 13 or later, and that notifications for your app and its channel are turned on in system settings.No android event source found for this workspace
You see this when you enable the Android (FCM) card before your workspace has an Android event source. Create an Android event source, then click Enable again. If your workspace has more than one Android event source, contact Hightouch support.Next steps
- Preview and test to render a message against real profiles before you send it.
- Send a campaign to schedule your first push to an audience.