Skip to content
Menu

Push notifications

Testing push

Markdown version

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

1. Turn on verbose logging

swift
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.

Set the level back to the default (warning) for release builds.

2. Register the test device

  1. Install the app, sign in as the test user, and allow notifications.
  2. Confirm no Herald rejected a batch line appears after the push token is sent. Herald needs a user token: call setUserToken means the user token is missing or wrong, and Herald has not stored the push token yet.
  3. Note the device token if you want to use a provider console. On iOS, log the hex form in didRegisterForRemoteNotificationsWithDeviceToken; on Android, read it from FirebaseMessaging.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:

json
{
  "aps": { "alert": { "title": "Test", "body": "Tap to open today's plan" }, "sound": "default" },
  "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.

FieldRules
External IDThe ID the user signed in with, up to 200 characters
ChannelPush, Content card or In-app modal
TitleRequired, up to 200 characters
BodyRequired, 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_test key so you can tell it from a real send.
  • Content card and In-app modal create a message for the user, with a test extra set to true. 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:

ResultMeaning
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: reasonHerald could not build or deliver the push, for example a missing credential on the connection.

Verify it works

  1. The notification appears, with the app in the background and again in the foreground.
  2. Tapping it opens the app and the deep link's screen.
  3. With debug logging on, the next batch after the tap is accepted. It carries a push open interaction.

Common failures

SymptomLikely causeFix
No notification, no errors in the appThe user is anonymous, or verification is Optional and no token was sent, so Herald stored no push tokenCall identify and setUserToken before testing
Herald rejected the app key: check the publishable key in configureWrong app key, or the connection is not activeCheck the key on the Mobile SDK card
Herald needs a user token: call setUserTokenA missing or wrong user token under RequiredCheck your token minting and call setUserToken after identify
APNs BadDeviceTokenToken and APNs environment do not matchTest a development build against sandbox, or a TestFlight build against production
APNs DeviceTokenNotForTopicBundle ID on the connection differs from the app'sFix the bundle ID on the connection
APNs InvalidProviderTokenKey ID or Team ID does not match the .p8 keyRe-enter the key details
FCM SENDER_ID_MISMATCHService account from another Firebase projectUse the project in the app's google-services.json
iOS: no banner in the foregroundwillPresent is not implementedReturn .banner from willPresent
Android: no notification in the foregroundAnother messaging service receives FCM messagesRemove one, or call HeraldNotifications.handleRemoteMessage from yours
Taps open the app but are not countedTaps are not forwarded to the SDKCall handleNotificationResponse (iOS) or handleNotificationIntent in onCreate and onNewIntent (Android)
Push arrives lateThe dispatcher runs less often than every minuteAsk your Herald operator to schedule it every minute

Next

See Herald decide live →