The issue you’re experiencing could be related to either software or hardware. Here are some steps you can try to resolve it:
1. Check for iOS updates: Ensure your iPhone is running the latest iOS version by going to Settings > General > Software Update.
2. Check for problematic apps: Sometimes, poorly optimized apps can cause random restarts. Update all your apps via the App Store and monitor if the issue persists.
3. Reset settings: Go to Settings > General > Reset > Reset All Settings. This won’t delete your data but will reset system preferences, which might resolve the issue.
4. Perform a clean install of iOS: Back up your data via iCloud or Finder and restore your iPhone to factory settings. This can help eliminate software bugs.
If none of these steps work, it’s possible there’s a hardware issue. Since your iPhone is still under warranty, consider contacting Apple Support or visiting an Apple Store for further assistance.
I hope this helps!