Step 1: Back up your data and contacts and remove your SIM card.
Step 2: Log out of iCloud—this ensures your iCloud data will not be erased.
Step 3: Sign out of all apps, clear the data, and uninstall.
Step 4: Sign out of services like iTunes and iMessage. (
Deregister if switching to a non-Apple phone.)
Step 5: Turn off Find My iPhone.
Step 6: Wipe your phone in Settings > General > Reset. Tap Erase All Content.