How to send SMS in appium for real device

Hi, is it possible to send SMS using Appium

You could do it with Python:

http://appium.io/docs/en/commands/device/network/send-sms/ (Android emulator only)

So it means it’s not available in iOS, right?

@wreed But actually I have an app - need to login or register, I get verification code via interface, how to make it happen and automate to test the login and register UI interface

But I want to do it using appium, how to make it happen, I test it on the real device.
@mykola-mokhnach

@MarcSteven I don’t think you are describing the problem very well. Maybe you should describe the situation and give some particulars. No offense but I’m not a mind reader.

Talk me through it as though I don’t know anything about your situation and I need a decent amount of detail. Help me help you.

1 Like

Yeah, as below:
It’s a scene about register for the app
1, input the mobile number
2, send the verification code
3, input the verification code
4, input the new password
5, click the register
and then the flow is over

@wreed

This is very different from the original question:

I’m going to guess that you have the app and have been able to install with appium, and have put in the mobile number, but are not able to get the SMS message? Is that the problem?

I’m looking at your next post:

So when I see this I’m thinking that you have the verification code, from an interface (perhaps a restful api?). I’m going to go over your flow and try to restate the problem:

Please take a look and tell me if I’m getting the gist of the problem.

@wreed Yeah right
It’s the use scene about the user login /register/forget password. It needs verification code to input and then all works!

Ok, sounds like you are all set then!

@wreed Do you have solutions for this ?

@wreed I found a solution to do it as these steps:

1.Launch SMS application

2.Retrieve the “code”

3.Launch your Application

4.Enter the retrieved “code” for verification
But I cannot find the solutions to open the message app using python and I read the appium doc, cannot find the api, only one method , launch app, do you have ideas?

You’ve finally asked the question! For the future, could you take a look at this page, and follow the guidelines for asking questions. You really need help in this area:

So it looks like you don’t know how to background the app and then navigate to another app. Take a look here for backgrounding the app:

https://appium.io/docs/en/commands/device/app/background-app/

There is specific Python code there for you. I would suggest that if you can get the verification code from another source, say from an interface, you do so. But if you have no choice you can background the app under test and navigate to the other app to retrieve the verification code.

Thank you so much, well noted!

Other very simple way to send SMS from any Android device is by using ADB command, for example:

adb shell service call isms 7 i32 0 s16 "com.android.mms.service" s16 "+1234567890" s16 "null" s16 "Hey\ you\ !" s16 "null" s16 "null"

Maybe constructing some lib in any language and calling this command works for you :slightly_smiling_face: