Skip to content
TestLine Menu
TestLine
mobile

How to test push notifications and deep links in a mobile app

A matrix of app states for notifications, commands for test sends to a simulator and emulator, how to check Universal Links and App Links, and the most common bugs.

author
Artur Machowski, Senior QA Engineer
published
reading
6 min

Short answer

You test push notifications in three app states (foreground, background, closed), with the permission granted, denied and revoked, checking that tapping opens the right screen. You test deep links with the app installed and not installed, with the user logged in and logged out, and from different sources: email, SMS, messenger, browser. A test send to the iOS simulator takes one command, xcrun simctl push, and a deep link on Android takes adb shell am start. Do the final tests on physical devices.

Push notifications: the state matrix

app statewhat to check
foregroundthe notification shows (in-app banner or system one) and doesn’t interrupt what the user is doing
backgroundthe notification appears in the notification centre, tapping opens the right screen
closedsame as background, plus the app starts straight on the target screen
permission deniedthe app works, doesn’t keep asking, shows how to turn notifications on
permission revoked in settingsno errors, the backend doesn’t treat it as a failure
logged-out usernotifications for the previous account don’t arrive
several devicesthe notification reaches all the user’s devices, or as agreed

On top of that: content with non-ASCII characters such as Polish letters, long text, an image in the notification, the badge count on the app icon, and a notification for a screen that no longer exists.

Test sends

iOS simulator, with a payload.json file:

xcrun simctl push booted com.example.app payload.json
{
  "aps": { "alert": { "title": "Order shipped", "body": "Parcel 12345 is on its way" } },
  "screen": "order",
  "orderId": "12345"
}

On a physical device and on the Android emulator you send notifications through the service the app uses, usually Firebase Cloud Messaging: from the Firebase console (a test message to the device token) or from the backend on staging. The second is better, because it checks the whole path, including the server-side logic.

scenarioexpected result
app installed, user logged inthe target screen opens with the right data
app installed, user logged outlogin, then the target screen, not the home screen
app not installedthe website or the store listing
link from email, SMS, messenger, browserthe same behaviour everywhere
link with parameters, e.g. a discount codethe parameters reach the app
link to a resource that doesn’t exista clear message instead of a blank screen

On Android you can fire a deep link without tapping anything:

adb shell am start -W -a android.intent.action.VIEW -d "https://example.com/order/12345" com.example.app

On the iOS simulator: xcrun simctl openurl booted "https://example.com/order/12345".

For an ordinary https URL to open the app:

  • iOS: an apple-app-site-association file under /.well-known/ on the domain, reachable without redirects, with the correct app identifier;
  • Android: an assetlinks.json file under /.well-known/ with the fingerprint of the certificate the app is signed with.

The most common bug: the file for the test build has the test certificate’s fingerprint, while the store app is signed with a different one. It works on staging, and on production links open the browser. Check both files after any change of domain, redirects or certificate.

How I can help

Notifications and deep links are points 28-31 in the mobile app pre-launch checklist. I check them as part of mobile testing on physical iOS and Android devices, together with the rest of a pre-launch review for PLN 6,000-10,000 net. Describe your app in the contact form.

Frequently asked questions

How do you test push notifications?

In three app states (foreground, background, closed), with the permission granted, denied and revoked in settings, checking that tapping opens the right screen. You can do part of it on a simulator and emulator, the rest on a physical device.

How do you send a test notification to the iOS simulator?

With xcrun simctl push booted, the app's bundle ID and a JSON file with the notification payload. On a real device you send it through the notification service, e.g. Firebase Cloud Messaging, from the console or from the backend on staging.

How do you test a deep link on Android?

With adb shell am start using the VIEW action and the link URL. For App Links also check that the assetlinks.json file on the domain is reachable and correct, because without it the link opens the browser instead of the app.

What are Universal Links and App Links?

Ordinary https URLs that open the app instead of the browser when it's installed. On iOS they need an apple-app-site-association file on the domain, on Android an assetlinks.json file. Without the app, the link opens the website.

What breaks most often in deep links?

The link opens the app but on the home screen instead of the target, doesn't work when the user isn't logged in, loses parameters, doesn't work from some apps (e.g. email clients or messengers), or stops working after the files on the domain change.

Got a release in a few weeks?

Describe your project in the form. I'll reply with questions about scope or an initial test plan.