If it's an iOS device, do a back-up and then erase phone. Restore the phone and avoid installing unknown stuff like Configuration Profiles or trusted root certificates.
If you have an Android device...
- short check > uninstall all unused and unknown apps, check device admin apps - revoke access to unknown apps. A RAT should also drain battery so you can check for apps that do that and are unknown by you.
- long process> back-up media files (copy photos, videos, docs etc. to other storage) do a factory reset and install only apps you trust from the store. Recopy your media files.