This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.
19 / 19
Nov 2017

Hi,

There as been couple request to read SMS received, mainly SMS containing some kind of verification code (OTP). This is my attempt to do so in a more standard way (without having to write code for each native messaging app).

For Android

  • I picked one random SMS Popup App from play store and extracted the apk. You can access it in here: SMSPopup.apk190
  • I implemented a class where you can install the SMS reader app, enabled it, read SMS and uninstall it. The class is available in here: ExtractCode.java336

  • I did not spent time checking if SMSPopup was already installed or not, so I uninstalled it every time, so that the enable process works without problems. But I left the instructions in comments on how to do it, if you want to spent time doing it.

  • The way I called the methods in the small example I did was:

    AppiumDriver driver = Drivers.getDriver(device);
    
    ExtractCode eCode = new ExtractCode(driver);
    eCode.installSMSAPK();
    eCode.configureSMSAPK();
    String mySMS = eCode.returnSMS();
    eCode.uninstallSMSAPK();

For iOS

I don't have any MAC in here or have tried this in a long time, so I'll just post how I did it, when I needed it.

  1. In iPhone go to Settings
  2. Go to Notifications
  3. Tap on Messages
  4. Select Alerts on Alert style when unlocked section
  5. Make sure options Show Previews is enabled

SMS will be received in a dialog like it appears in the image below, and you should be able to read the SMS and close the dialog before proceeding your tests (attention: any received SMS will trigger this dialog, so take than into account on your tests).
26

Hope any of this can help someone.

  • created

    May '16
  • last reply

    Nov '17
  • 18

    replies

  • 7.7k

    views

  • 7

    users

  • 8

    likes

  • 7

    links

4 months later
2 months later

link is also broken with 404 "An error has been encountered in accessing this page." :frowning:

Thanks @KatzBo for letting me know.

I'm not 100% sure of my original code :slight_smile: but I re-uploaded the code and APK on new links

are the links useable?
I read alot of your replys about the OTP sms test ...
Can you suggest me what is the best way to check an OTP sms msgs?

I am testing Android with Java using Eclipse ...

1 month later

@Telmo_Cardoso
could you kindly upload SMSPopup.apk to a free download site? for apkshared site have to be signup with your credit card information, could you upload the APK file to for example google drive?
thanks.

Hi,

changed the link. Please be aware that I have no rights over that app and it is just a random app that I downloaded from the store.

Thanks for the hint

4 months later

"SMS ON IOS" does not seems to work anymore.
Appium ver: 1.6.4 (appium desktop 1.0.2-beta.2)
iPhone 6 IOS 10.3.2

3 months later

Hi Telmo
For XCUITest when I open notification panel to read SMS directly from there
the appium logs send error:

[debug] [XCUITest] Connection to WDA timed out

[debug] [iProxy] recv failed: Operation not permitted

I can not find msg locator
when I close notification WDA return to work

2 months later

Hey,
I tried this but getting an error. I have already installed the App and configured to “Accept”. So have commented out the code.

ExtractCode eCode = new ExtractCode(driver);
//eCode.installSMSAPK9();
// eCode.configureSMSAPK();
String mySMS = eCode.returnSMS();
// eCode.uninstallSMSAPK();
System.out.println(mySMS);

I am getting the error: ava.lang.Exception: The following id was not found: net.everythingandroid.smspopup:id/popupMessageMainlayout
But i see the pop on the mobile phone running the case.

I had opened a WebApp which sent an sms and I am trying to read it.
Do i need to explicitly pass control to this pop? How?
If not, what can be wrong. Please help.

automate it like its your app… open inspector you prefer, see elements and try to found them in debug mode.

I am using the same smspopup app from playstore which you had used. It throws me the following error:
java.lang.Exception: The following id was not found: net.everythingandroid.smspopup:id/popupMessageMainlayout

while uiinspectorviewer shows me that this is present.

Try to inspect in debug mode directly from your IDE. If its present on uiautomatorviewer, it should appear also during automation.

I think I am not able to switch from my webApp to this view. Donno how to do it.