Is it possible to read the OTP sent to the device and switch back to your application?

I have an application which I need to automate, the steps for it are :-

  1. App installing, opening the app
  2. Enter your mobile number
  3. Mobile number receives an OTP which is a 4 digit number
  4. Hop to the message box and read the message from there.
  5. Come back to the app and enter the OTP retrieved from the message box.

I am stuck with how to switch from your native application to the message box and back again. Any help would be greatly appreciated. TIA :smile:

Watch “Appium Tutorial- Switching between apps (Contact …” on YouTube
Appium Tutorial- Switching between apps (Contact …: