This document explains how to test push notifications and event tracking.
- Verify FCM Token Retrieval
- Send Test Notification
- Confirm Notification Reception
- User Actions (Tap, Dismiss, Link Click)
- Verify Event Sending to Treasure Data
# Run the app in Xcode and check the console
# You should see logs like:
Firebase initialized
APNs token registered
🔑 FCM token: dXkz8H...(long string)Copy the FCM token (to be used for test notification sending).
# Install and launch the app
adb logcat -c # Clear logs
adb logcat | grep "FCM"
# You should see logs like:
Firebase initialized
FCM token: dXkz8H...(long string)- Run the app on an Android device or emulator with Google Play Services and allow notifications.
- Get the app's current FCM registration token from Logcat.
- In Engage Studio, open a Mobile Push campaign and select the Campaign Content tab.
- Click Create mobile push notification, or Edit for existing content. The Mobile Push Notification Editor opens.
- Under Mobile push authentication, select the authentication configured for the app's Firebase project.
- Enter Title and Message. To test images or tap behavior, configure Image and On click behavior.
- Click Send test.
- Enter the token in Test device token.
- Click Send.
Check Logcat for the received FCM data payload and confirm that the notification appears. Repeat the test with the app in the foreground and in the background. Verify the delivery event as described in Section 5.
- Run the app on a physical iOS device, allow notifications, and copy its current FCM registration token from the Xcode console.
- In Engage Studio, open a Mobile Push campaign and select the Campaign Content tab.
- Click Create mobile push notification, or Edit for existing content. The Mobile Push Notification Editor opens.
- Under Mobile push authentication, select the authentication configured for the app's Firebase project.
- Enter Title and Message. To test images or tap behavior, configure Image and On click behavior.
- Click Send test.
- Enter the token in Test device token.
- Click Send.
- Verify notification display, tap behavior, and campaign events in the foreground and background.
Note: Background delivery events are recorded only when iOS invokes the background callback.
Prerequisites:
- Xcode (full version) must be installed
- Install Xcode from the App Store
- Command Line Tools alone are not sufficient
- After installation, set Xcode path:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
# 1. Verify Xcode developer tools path
xcode-select -p
# Expected output: /Applications/Xcode.app/Contents/Developer
# If it shows /Library/Developer/CommandLineTools, run the command above
# 2. Launch simulator
open -a Simulator
# Or check available simulators and boot:
xcrun simctl list devices available
xcrun simctl boot "iPhone 15"
# 3. Build & install app (run from Xcode)
# Xcode > Product > Run (⌘R)
# 4. Send test payload
xcrun simctl push booted com.treasuredata.pushsample \
shared/test-payloads/test-notification.apnsNote:
simctl pushinjects the payload locally and bypasses FCM and APNs delivery.xcrun simctlcommands require Xcode to be installed.
Use shared/test-payloads/test-notification.apns with simctl push to test local notification handling on iOS Simulator. For campaign delivery, use Engage Studio Send test as described above.
- Payload format: Places
apsand custom data at the root, with the simulator-onlySimulator Target Bundle. - Message ID: Does not include an FCM-generated message ID.
- Notification options: Omits
soundandbadge, matching the Engage Studio payload.
| Test | Simulator fixture |
|---|---|
| Open app | Remove link |
| Open a web URL | Set link to an allowed HTTPS URL |
| No image | Remove image and aps.mutable-content |
Use a publicly accessible image URL with a file extension, such as .jpg or .png.
| Platform | Campaign ID | FCM message ID |
|---|---|---|
| Android | RemoteMessage.data["tdCampaignId"] |
RemoteMessage.messageId |
| iOS | userInfo["tdCampaignId"] |
userInfo["gcm.message_id"] |
The app records tdCampaignId as campaign_id and the FCM message ID as message_id in events. FCM supplies the message ID as metadata.
When notification arrives:
- App in Foreground: Banner will be displayed
- App in Background/Closed: Will appear in notification center
In the foreground, verify the following log. In the background, it appears only when iOS invokes the callback.
Delivery event added to Treasure Data SDK
adb logcat | grep -E "FCMService|PushEvent|Notification"
# Expected logs:
FCM message received from: ...
Campaign ID: <tdCampaignId from the payload>
Message ID: <FCM-generated message ID>
Delivery event added to Treasure Data SDK
Notification displayed (ID: ...)- Tap the notification
- App launches, deep link or web link opens
- Verify in logs:
iOS:
Open event added to Treasure Data SDK
🔗 Deep link opened: tdpushsample://product/12345
📦 Navigating to product: 12345
Android:
Open event added to Treasure Data SDK
Deep link opened: tdpushsample://product/12345
Navigating to product: 12345
iOS state checks:
- Repeat the tap check with the app in the foreground, background, and terminated.
- Confirm that each tap records one
openevent and opens the configured screen or web link. Open app displays the app without navigating to a link. - Background execution is not guaranteed, so do not require a
deliveryevent for the terminated-state tap check.
- Swipe notification to the left to dismiss
- Verify in logs:
Dismiss event added to Treasure Data SDK
Payload:
{
"link": "tdpushsample://product/12345"
}Platform Notes:
- Android: In Engage Studio, set On click behavior to Open a deep link and enter the URL. It is sent as
data.link. - iOS: Use
linkat the root of the local APNs payload, matching the custom data key used by Engage Studio.
When tapping notification:
- Navigate to corresponding screen in the app
deeplink_openevent is recorded
When notification payload includes link field:
{
"link": "https://www.treasuredata.com"
}When tapping notification:
- Open URL in Safari (iOS) or Chrome Custom Tabs (Android)
link_openevent is recorded
- In the Xcode console or Logcat, check for
Delivery/Open/Dismiss event added to Treasure Data SDK. This confirms that the SDK accepted the event locally. Use the Treasure Data query below to verify upload. - The iOS "Queued Events" counter and "Upload Events Now" button use the legacy EventQueue and do not show notification events. Notification events are added directly to the Treasure Data SDK.
- On Android, "Upload Events Now" manually uploads SDK events.
- Log in to Treasure Data Console
- Queries > New Query
- Execute the following SQL:
SELECT
time,
type,
campaign_id,
message_id,
platform,
fcm_token,
user_id,
value,
app_version,
os_version,
device_model
FROM mobile.push_events
WHERE time > td_time_add(now(), '-1h', 'JST')
ORDER BY time DESC
LIMIT 100Expected Results:
This example shows events from an Engage Studio Send test with campaign ID 12345 and Open a deep link selected. FCM generates a message ID for each notification. simctl push does not generate an FCM message ID.
| time | type | campaign_id | message_id | platform |
|---|---|---|---|---|
| 2025-01-15 10:30:00 | delivery | 12345 | FCM-generated ID |
ios |
| 2025-01-15 10:30:05 | open | 12345 | FCM-generated ID |
ios |
| 2025-01-15 10:30:06 | deeplink_open | 12345 | FCM-generated ID |
ios |
Calculating Delivery Rate:
SELECT
campaign_id,
COUNT(*) as total_sent,
COUNT(CASE WHEN type = 'delivery' THEN 1 END) as delivered,
COUNT(CASE WHEN type = 'open' THEN 1 END) as opened,
ROUND(100.0 * COUNT(CASE WHEN type = 'open' THEN 1 END) / COUNT(CASE WHEN type = 'delivery' THEN 1 END), 2) as open_rate
FROM mobile.push_events
WHERE time > td_time_add(now(), '-24h', 'JST')
GROUP BY campaign_id
ORDER BY total_sent DESC- Launch the app
- Retrieve FCM token
- Send test notification
- Confirm notification reception (delivery event)
- Tap notification (open event)
- Verify events in Treasure Data
- Send notification with image URL
- Confirm image displays in notification
- Tap to verify functionality
- Send a notification with the deep link in
data.link(Android) orlinkin the iOS notification userInfo - Tap notification
- Confirm correct screen transition in app
- Verify
deeplink_openevent sent to Treasure Data
- Send notification with
linkfield - Tap notification
- Confirm link opens in Safari/Chrome Custom Tabs
- Verify
link_openevent sent to Treasure Data
- Enable airplane mode
- Receive notification
- Tap notification
- Confirm event queued (verify in logs)
- Disable airplane mode
- Restart app
- Confirm events automatically uploaded
See TROUBLESHOOTING.md for details.
No Notifications Received:
- Confirm FCM token is correctly retrieved
- Check project settings in Firebase Console
- iOS: Verify APNs authentication key is set
- Android: Verify google-services.json is correct
No Events Uploaded:
- Check network connection
- Verify TD API Key is correct
- Check HTTP response code (200 = success)
No Images Displayed:
- iOS: Confirm Notification Service Extension is correctly configured
- Verify image URL uses HTTPS
- Check image size (recommended: under 1MB)