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