Open Settings and tap Messages. Tap Keep Messages and choose Forever.
Make Sure "Delete Old Messages" is Off
You can disable the option and avoid getting your messages deleted as follows: Open your Messages app and head into the Settings menu. Turn the toggle for Delete old messages to the off position.
Scroll down to the section labelled MESSAGE HISTORY. Tap Keep Messages. Choose either 30 days or 1 Year. This will delete messages older than one month or one year.
You cannot install a restriction to prevent deletion of Text Messages on the iPhone.
Your iPhone keeps all text messages by default, but you might not want that. Here's how to make your iPhone automatically delete old messages. By default, your iPhone keeps your iMessages and SMS texts forever. If you have multiple years of synced messages with iCloud, it can take up valuable space.
Note: Deleted messages remain in your Recently Deleted folder for up to 30 days, and you can recover them.
Tap the three-dot menu in the upper-right corner and open the Recycle bin. Check your deleted text messages. Long tap the message you want to retrieve. Select Restore at the bottom and check the same in your primary inbox.
One possible reason is that you set your iPhone to keep the messages for only 30 days or 1 year. In addition, iOS updates may also delete some types of data on the device including text messages.
All of your deleted text messages can be found in the Messages app. To find your trashed messages, open Messages and tap the Filters option in the top left of your text threads. Here you can filter your text messages by known senders, unread messages and more. However, the option we want is Recently Deleted.
Clearing or deleting your messages on your devices doesn't mean the data is permanently gone, it's just been filed away differently.
Why do my text messages disappear on Android? There a number of reasons that may cause the issue. It can be an accidental deletion or loss, recent app updates that affect your text messages, date and time setting in your phone is not updated, Android system or app version that needs an update, and many others.
You can choose to automatically delete your iMessages from your device after 30 days or a year, or to keep them on your device forever. For your convenience, iMessages are backed up in iCloud and encrypted if you have enabled either iCloud Backup or Messages in iCloud.
You need iOS 16, iPadOS 16.1, or later to recover deleted messages and conversations. You can only recover messages and conversations that you deleted within the last 30 to 40 days.
Some phone companies also keep records of sent text messages. They sit on the company's server for anywhere from three days to three months, depending on the company's policy. Verizon holds texts for up to five days and Virgin Mobile keeps them for 90 days.
Once you delete a text message or conversation on your iPhone, it gets immediately moved to a folder within the Messages app called Recently Deleted. However, the tricky part is that only iPhones running iOS 16 or later allow users to view this folder.
You can only recover messages and conversations that you deleted within the last 30 to 40 days. If you delete a message before you update to iOS 16, iPadOS 16, or later, you can't recover that message.
With Messages in iCloud, anything you delete from iPhone is also deleted from your other Apple devices where Messages in iCloud is turned on. Deleting messages changes only your own Messages conversations, not those of your recipients.
Deleted text messages are truly GONE. Nobody can access them. Unless you have a program installed that archives/backs up messages.
Where's the data. The iMessage history that powers your Messages app is stored in a database file in your computer's hard drive, in a hidden folder named Library which, in turn, is in your username folder. You can usually find your username folder on the side bar of the finder.
Incorrect settings.
You can go to Settings > Messages > Keep Messages to have a check. If it is not Forever, it is the reason that iPhone deleted all messages.