How to Test and Automate Push Notifications on Real Devices

test push notifications

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:

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

  1. Validating Payload Structure

The notification delivery could fail, or messages might be malformed due to incorrect JSON format.

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

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

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

  1. Once you log in to your TestGrid account, navigate to the Real Device Cloud screen.
  2. From the wide range of available real cloud devices, select the configuration that you would want to test your application on.
    AD 4nXcwq gwOa2L6NsAkr pfWn60SFmnWX2qczfJquNymELORPJvzgQj2dWVbAOI3KIQgsAjuRKPTqiIqy1x dQ74kbIK5Z8 mshfn8HeY6d77lmz5sa3cNok RCrRceK7eGba34iIN?key=AvoWniGwAu1PgEqwTbPEvg
  3. Once connected to a device, upload the APK that you want to test.
  4. Now, trigger the notification.
  5. Next, swipe down the mobile screen just like you do in your physical devices, and you will see the notification.
  6. Alternatively, you can click on the Notification icon on the right pane and the same window will appear.
AD 4nXcE8 wuhJiPE3eq7aDPiO vkInUib6D wgcgnpCfL7sM51Eo0IFu0IKl71wAga2YVFDi2e33FA7rlcne UwRuxcjwO1Pfy x8vyVT6ue9Dp fE1GZSiQa9bLU3ooOnv8bX0kM8t Q?key=AvoWniGwAu1PgEqwTbPEvg
  1. 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:

  1. After logging in to TestGrid, navigate to Real Device Cloud.
  2. 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.
AD 4nXesmeqMHj BvdS3jJyxSYiUwEWoINyh17sgQyzxmpzD4RzsQWE846W2XwiHlFo0Zy8T3m EfvGTVwNIDhjPtbQ8 CMgmLsCXdm5wrE2NE4mg51JcCAInyqHhaqogYbkhKG7XgRYBw?key=AvoWniGwAu1PgEqwTbPEvg
  1. You will now see Device Capabilities for the device you want to select. Copy the capabilities in the programming language of your choice.
AD 4nXfLAxtxGCXRuT57jlPc mkJ o7336WxsReRWnoGk2Y6KZ7Vk0AA7IJCu8t7yrlIXJ2sW9JX66sUybx7O 8OzvrKz4M7yZ f6q98YKHItSKmeL
  1. 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.