In our digital age, much of our privacy is in our pocket. It’s in our personal gadgets.

Apple has it all: What to do before selling or giving away your iPhone, iPad, or iPod touch! This is an important step to do before you decide selling your Apple idevice.

You can use these steps to remove your personal information from a device, even if you don’t have it anymore. This is very very important because there are a lot of personal content, including your Gmail and Facebook account you don’t others to have access to. This also applies to your other electronic gadgets and computers.

If you still have your iOS device
You shouldn’t manually delete your contacts, calendars, reminders, documents, photo streams, or any other iCloud information while you’re signed in to iCloud with your Apple ID. This would delete your content from the iCloud servers and any of your devices signed in to iCloud.
On your device with iOS 10, make sure that you sign out of iCloud before you erase your device.

Follow these steps:
If you paired an Apple Watch with your iPhone, unpair your Apple Watch.
Back up your iOS device.
Tap Settings > iCloud. Scroll down and tap Sign Out. In iOS 7 or earlier, tap Delete Account.
Tap Sign Out again, then tap Delete from My iPhone and enter your password.
Go back to Settings and tap General > Reset > Erase All Content and Settings. If you turned on Find My iPhone, you might need to enter your Apple ID and password.
If asked for your device passcode or Restrictions passcode, enter it. Then tap Erase [device].
Contact your carrier for help transferring service to a new owner. If you aren’t using a SIM card with your device, you can contact them to get help transferring service to the new owner.
When you erase your iPhone, iPad, or iPod touch, Find My iPhone and Activation Lock is turned off.

If you no longer have your iOS device
If the steps above weren’t completed and you no longer have your device, use these steps:
Ask the new owner to erase all content and settings using the above steps.
If you’re using iCloud and Find My iPhone on the device, sign in to iCloud.com or the Find My iPhone app on another device, select the device, and click Erase. After the device has been erased, click Remove from Account.
If you can’t follow either of the above steps, change your Apple ID password. This won’t remove personal information that’s stored on your old device, but it will prevent the new owner from deleting your information from iCloud.
If you’re switching to a non-Apple phone, deregister iMessage.
If you’re using Apple Pay, you can remove your credit or debit cards at iCloud.com. Choose Settings to see which devices are using Apple Pay, then click the device. Next to Apple Pay, click Remove.

Learn more
Make a backup of your iOS device or restore from a backup.
Get help if your iOS device is lost or stolen.
Learn about Find My iPhone Activation Lock.
*When you tap Erase All Content and Settings, it completely erases your device, including any credit or debit cards you added for Apple Pay and any photos, contacts, music, or apps. It will also turn off iCloud, iMessage, FaceTime, Game Center, and other services. Your content won’t be deleted from iCloud when you erase your device.
Last Modified: Oct 11, 2016

source: https://support.apple.com/en-us/HT201351