The answer is unfortunately: it depends! If you have a backup of the iPhone made before the messages were deleted (either iCloud or made in iTunes on your computer), you can either get the messages out of that backup, or restore the backup to get the messages for sure. Keep in mind that restoring a backup is going to erase the new contents on your iPhone though, so that may not be what you want to do.
If you don't have a backup made before the messages were deleted, there's still a chance that the messages are recoverable. When you delete a message in Messages, the database entry gets tagged for reuse, rather than obliterated - there's a lot of third party tools that will analyze a text message database from an iTunes backup to see if the message record is still there in the database to read. I'm the developer for one of the third party tools - Decipher TextMessage - that will do the analysis on Message app databases in a backup. You can definitely google around to see your options for tools though.
Generally, there are 3 solutions:
- Restore your device from a backup in iCloud or iTunes if the messages existed when the backup was created. The restore needs to erase all the settings and content on your iPhone, so think twice before you decide to restore the phone.
- Extract the messages from the backup with an iTunes/iCloud backup extractor if you don’t want to lose the data generated after the backup.
- Recover deleted text messages directly from the device with a third-party program if no iTunes or iCloud backup was created.