Push notifications
Testing push
Turn on verbose logging, send a test notification to one device, and fix the most common push failures.
This guide gets one test device receiving Herald pushes, with enough logging to see each step. Test on a physical device or an emulator with Google Play services; check the push path end to end before you test content.
Before you start
- Push set up: iOS setup or Android setup.
- A test External ID your app can sign in as.
1. Turn on verbose logging
Herald.configure(appKey: "YOUR_APP_KEY", endpoint: URL(string: "https://YOUR_HERALD_HOST")!) { options in
options.logLevel = .debug
}Logs use the subsystem com.herald.sdk and the category Herald. Read them in the Xcode console, or in the Console app with the device connected.
Herald.configure(
this,
appKey = "YOUR_APP_KEY",
endpoint = "https://YOUR_HERALD_HOST",
options = HeraldOptions(logLevel = LogLevel.DEBUG),
)Logs use the tag Herald. Filter Logcat with tag:Herald.
Set the level back to the default (warning) for release builds.
2. Register the test device
- Install the app, sign in as the test user, and allow notifications.
- Confirm no
Herald rejected a batchline appears after the push token is sent.Herald needs a user token: call setUserTokenmeans the user token is missing or wrong, and Herald has not stored the push token yet. - Note the device token if you want to use a provider console. On iOS, log the hex form in
didRegisterForRemoteNotificationsWithDeviceToken; on Android, read it fromFirebaseMessaging.getInstance().token.
3. Send a test push
From the provider console. This checks the device, the credentials and the SDK's handling, without Herald's decisioning. Include nexus_decision_id so the SDK treats the push as a Herald push; a made-up value is fine, because Herald credits only real decisions that belong to the user.
Use Apple's Push Notifications Console (in your developer account, under CloudKit Console) with your device token, your bundle ID as the topic and the environment that matches your build. Payload:
{
"aps": { "alert": { "title": "Test", "body": "Tap to open today's plan" }, "sound": "default" },
"nexus_decision_id": "test_1",
"deeplink": "lumen://plan/today"
}In the Firebase console, create a notification under Messaging, choose Send test message and paste the FCM token. Under Additional options > Custom data, add:
| Key | Value |
|---|---|
nexus_decision_id | test_1 |
deeplink | lumen://plan/today |
From Herald. This checks the full path, including the credentials on the connection. Use Send a test from Herald below. A send from an agent waits for Herald's dispatcher, which your operator runs on a schedule, so allow a minute or two.
Send a test from the Mobile SDK card
The Mobile SDK card on the connection's page has a Send a test form. It sends one message to one user now. Only admins can use it, and the Send test button stays disabled until the connection has an app key.
| Field | Rules |
|---|---|
| External ID | The ID the user signed in with, up to 200 characters |
| Channel | Push, Content card or In-app modal |
| Title | Required, up to 200 characters |
| Body | Required, up to 2,000 characters |
| Deep link (optional) | A link your app opens when the user taps |
What each channel does:
- Push goes to every active push token the user has, without waiting for the dispatcher. It carries a
herald_testkey so you can tell it from a real send. - Content card and In-app modal create a message for the user, with a
testextra set totrue. It expires after 24 hours so it does not stay in a real user's feed. Herald then sends a sync push so the app refreshes at once. See Silent push.
A test does not create a decision, so it does not count toward send caps or an agent's results. It uses the defaults for the channel, not a variant's delivery options.
The form shows one result:
| Result | Meaning |
|---|---|
| Sent. | The push was accepted by APNs or FCM, or the card or modal was created. |
| Queued. Delivery is being retried. | The push service did not accept it yet. Herald retries it. |
| Not sent: this user has no push token. | The user has no active push token, or every token is suppressed. Check the user is identified and verified. |
| Not sent: this user has no device registered with the SDK. | A card or modal needs a device that has opened the app as this user. |
| Failed: reason | Herald could not build or deliver the push, for example a missing credential on the connection. |
Verify it works
- The notification appears, with the app in the background and again in the foreground.
- Tapping it opens the app and the deep link's screen.
- With debug logging on, the next batch after the tap is accepted. It carries a push
openinteraction.
Common failures
| Symptom | Likely cause | Fix |
|---|---|---|
| No notification, no errors in the app | The user is anonymous, or verification is Optional and no token was sent, so Herald stored no push token | Call identify and setUserToken before testing |
Herald rejected the app key: check the publishable key in configure | Wrong app key, or the connection is not active | Check the key on the Mobile SDK card |
Herald needs a user token: call setUserToken | A missing or wrong user token under Required | Check your token minting and call setUserToken after identify |
APNs BadDeviceToken | Token and APNs environment do not match | Test a development build against sandbox, or a TestFlight build against production |
APNs DeviceTokenNotForTopic | Bundle ID on the connection differs from the app's | Fix the bundle ID on the connection |
APNs InvalidProviderToken | Key ID or Team ID does not match the .p8 key | Re-enter the key details |
FCM SENDER_ID_MISMATCH | Service account from another Firebase project | Use the project in the app's google-services.json |
| iOS: no banner in the foreground | willPresent is not implemented | Return .banner from willPresent |
| Android: no notification in the foreground | Another messaging service receives FCM messages | Remove one, or call HeraldNotifications.handleRemoteMessage from yours |
| Taps open the app but are not counted | Taps are not forwarded to the SDK | Call handleNotificationResponse (iOS) or handleNotificationIntent in onCreate and onNewIntent (Android) |
| Push arrives late | The dispatcher runs less often than every minute | Ask your Herald operator to schedule it every minute |