Use iCloud.com (Find My) to erase the iPhone if it’s signed in to Apple ID and “Find My iPhone” is enabled
After erasing, set up the iPhone again and restore from an iCloud backup (if available)
Use Recovery Mode with a computer only if the iPhone can’t be erased via Find My
If you forgot the passcode and don’t have access to Find My, contact Apple Support for account verification and next steps
If the iPhone is managed by an organization, contact your administrator for the appropriate unlock/reset process
