Test Push Notifications


is there a way to test push notifications ? (with Appium)
I understand that it’s not possible on emulators but let’s say i run it on real devices on some cloud service.
if its possible to test push notifs then, how to do it? can’t find much info on it on the web :smile:

relevant for both iOS and Android.


1 Like

iOS - no (due to sandbox limitation on real device), Android - yes.

With android you can use (Java) driver.openNotifications() and tap on notification.

Hi, i can’t get my driver to contain openNotifications() method.

i’m declaring the driver as AppiumDriver (and instantiated as AndroidDriver in runtime) since i have a generic wrapper for iOS and Android. I can only get openNotifications() if i declare the driver as AndroidDriver.

solved with casting, sorry :slight_smile:

Thanks for the solution for Android. But is there any way to test it on iOS Simulator? Really appreciate if any help provided

iOS Simualtor = no way.

@Roy_Varum: I am having problem with casting. I am getting following exception while casting

cannot be cast to io.appium.java_client.android.AndroidDrive

@Roy_Varum: I am having problem with casting. I am getting following exception while casting

cannot be cast to io.appium.java_client.android.AndroidDrive

Here is what I am trying to do

AndroidDriver<?> obj; obj=(AndroidDriver<?>) driver; // driver is object of AppiumDriver class

Please let me know if I am missing anything?

openNotifications method is possible with iOS device? if it is not support to simulator

no.on real device you can’t tap outside test client.

is there any progress/workarounds for appium testing APN on iOS simulator/real device?

I’ve added this as a step in my functional tests (assuming a mock will suit your purpose).


SimulatorRemoteNotifications is a library to send mock remote notifications to the iOS simulator.

The library extends UIApplication by embedding a mini server that listen for UDP packets containing JSON-formated payload, and a service to send notifications to the mini server.

This project includes the iOS Simulator Notifications MacOSX app to help you send the mock notifications.

Note that SimulatorRemoteNotifications does not send notification through Apple’s Push Service.


I am able to open notification, correct behavior.

Now what to do if I want to click on the notification that actually comes in…How to verify that notification is in? How to click on notification?

I tried this code and it is not working.

@AndroidFindBy(uiAutomator = "new UiSelector().resourceId('android:id/title')")
    private List<WebElement> notificationTitles;

for(int i=0; i<notificationTitles.size(); i++)
    		System.out.println("Total notif "+notificationTitles.size());
    			System.out.println("JIo 4g is detected");
    			System.out.println("In if condition");

I decided to try a workaround to test push notifications. Currently, I jailbroken a device and I’m using this specific device just for push notification testing. I wrote a tweak to create an extra routine on the publishBulletin method (method used to add notifications to the notification center) in the iOS core. Therefore, I get the needed data in that method and export it to a log. I might not be able to access the notification center data, but access an external text file is possible.

I know this solution is not the most elegant one and also has nothing to do with appium, but I hope this might help someone. In addition, with the device being jailbroken, I am able to change the iOS date and time using the terminal, which is also needed for most push notifications to be triggered.

cannot be cast to io.appium.java_client.android.AndroidDriver any solution for this???

How to close the notifications in run-time (eg: message notifications other notifications).