Push notifications are an integral part of modern mobile applications, driving significant user engagement. Whether it’s reminding about an abandoned cart, sending a time-sensitive offer, or regarding any important update, push notifications are quick, direct, and effective. But what if they do not show up at all?
A non-working action button or an unpublished notification might get missed during development, but the users are quick to identify, and that’s where there is a risk of losing them. This is why push notification testing is not just helpful, but crucial. In this guide, we will walk through the importance of push notification testing and look at how we can do it for our mobile applications.
What are Push Notifications?
Push notifications are short messages delivered to a user’s device from an app that they have installed, even when the app is not running. They are generally routed through platform-specific services:
- FCM – Firebase Cloud Messaging for Android
- APNs – Apple Push Notification Service for iOS
These push notifications can be in the form of text messages, rich media like images and videos, deep links to app screens, and action buttons like reply or dismiss. Push notifications can be categorized as:
- Transactional notifications, for example, “Your order has shipped.”
- Promotional notifications, for example, “Flash Sale – 50% Off today!”
- Lifecycle or behavioral notifications, for example, “You left items in your cart.”
Why is Testing Push Notifications Important?
Push Notifications are an important part of the user journey in any mobile application. But these are often overlooked in QA cycles. These notifications should be tested rigorously, and below are the reasons why:
- Ensuring Delivery Accuracy
There might be conditions when FCM cannot deliver the message, like battery drainage, network drops, or some device policies. To ensure that notifications are delivered seamlessly, it is important to test the functionality thoroughly.
- Validating Payload Structure
The notification delivery could fail, or messages might be malformed due to incorrect JSON format.
- Validate the UI/UX Behaviour
Device state, like foreground, background, or killed, plays a major role in how push notifications behave. Additionally, some Android skins like MIUI or ColorOS handle notifications differently.
- Cross-Platform Differences
Real device testing is the only way to see how push notifications behave across different platforms. Something that works on Android 10 might break on Android 13.
- Functional Reliability
Deep-links, buttons, and swipe actions must perform as expected because broken actions can negatively impact engagement.
How to Test Push Notifications using TestGrid Real Device Cloud?
We will now see how we can test push notifications manually. As highlighted above, it is important to test across real devices to check the behaviour of the push notification functionality. But it becomes difficult to procure a wide variety of real devices. This is where platforms like TestGrid come to the rescue with their Real Device Cloud. Let us look at the step-by-step approach to test push notification manually using TestGrid’s real device cloud.
- Once you log in to your TestGrid account, navigate to the Real Device Cloud screen.
- From the wide range of available real cloud devices, select the configuration that you would want to test your application on.
- Once connected to a device, upload the APK that you want to test.
- Now, trigger the notification.
- Next, swipe down the mobile screen just like you do in your physical devices, and you will see the notification.
- Alternatively, you can click on the Notification icon on the right pane and the same window will appear.
- Once you see your notification, feel free to take the next steps in your testing.
Although it might seem that you can do the same steps on your physical devices, using TestGrid can help you in several ways:
- Access to real devices from multiple OEMs (Samsung, Xiaomi, Pixel)
- Logging, screen recording, and remote debugging
- Parallel device sessions
- Integration-ready APIs for automation
You can also use the real device cloud for your automation push notifications for the same scenarios. All you need to do is simply pass the capabilities of the device you would like to perform the test on. To do so, you can follow the steps below:
- After logging in to TestGrid, navigate to Real Device Cloud.
- On the real cloud devices available, click on the information icon corresponding to the mobile device you would want to test your APK on. Note that for this demo, I will be validating the system notification. You can validate your App notification as well by performing steps to launch the app and initiate the notification.
- You will now see Device Capabilities for the device you want to select. Copy the capabilities in the programming language of your choice.
- Once copied, paste the desired capabilities in your Appium or XCUITest setup code as shown below.
public class NotificationTest {
AndroidDriver driver;
@BeforeTest
public void setUp() throws MalformedURLException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "Galaxy S21 FE 5G");
capabilities.setCapability("platformVersion", "13");
capabilities.setCapability("platformName", "android");
capabilities.setCapability("automationName", "UiAutomator2");
capabilities.setCapability("udid", "- device udid -");
capabilities.setCapability("tg:userToken", "- your TestGrid token-");
capabilities.setCapability("systemPort", "4013");
capabilities.setCapability("uiautomator2ServerLaunchTimeout", "90000");
driver = new AndroidDriver(new URL("- TestGrid URL-"), capabilities);
}
@Test
public void testValidNotification() {
// Find Notification
WebElement notification =
driver.findElement(AppiumBy.androidUIAutomator("new UiSelector().textContains("Your Notification Text")"));
if (notification != null) {
System.out.println("Notification found: " + notification.getText());
// Click notification
notification.click();
} else {
System.out.println("Notification not found.");
}
}
@AfterTest
public void tearDown() {
//Closing the driver instance
driver.quit();
}
}
Upon execution, you will see the logs of your execution and corresponding results in the TestGrid’s execution dashboard.
Edge Cases For Your Push Notification Testing
While testing push notifications, it is very important to consider the real-world scenarios and validate them to see how the app responds.
- Simulate network loss during message delivery
- Checking notifications in Airplane mode activation and deactivation.
- Notification behavior due to Doze mode restrictions.
- Impact of permission restrictions on apps for notifications.
- Validation of concurrent multiple notifications.
Best Practices for Automating Push Notifications
- Always validate the changes on different devices and OS versions.
- Validate the test cases for different device states, like background, foreground, or Doze mode.
- Check for user experience with the icons, sound, vibrations, and action buttons.
- Avoid publicly exposing FCM server keys; store them securely using environment variables or secrets managers.
- Try integrating push notification testing into your CI/CD pipelines.
- Test for performance metrics by validating multiple concurrent notifications.
Conclusion
Push notifications are an essential tool for user engagement. Without thorough testing, they can fail silently and invisibly. By leveraging TestGrid’s real device cloud, you can ensure testing push notifications across a wide range of devices, both manually and through automation. Whether you are shipping a new feature or optimizing engagement, don’t let notifications be your weak link. Test – early, often, and smart.