This is good advice: (It's what I would do)
https://macreports.com/your-iphone-has-been-hacked-immediate-action-needed-message-how-to-fix/
Scaring and tricking users into thinking that their devices are somehow compromised is a long-running scam. Apple users have been suffering from this scam, too, even though it is a known fact that security flaws in Apple devices are very rare. A common scam targeted toward iPhone or iPad users is the your iPhone has been hacked scam. Sometimes you may get a popup message or be redirected to a screen saying your iPhone is hacked, compromised or accessed, and your actions are being watched without your authorization. The message is designed to scare you. The message also urges you to take immediate action,
Do not interact with the notice
Do not tap anywhere. Usually, these popups have fake buttons. For example, it may say, Close, but that may be a button for something else instead of closing it. You may be redirected to another page or the App Store if you tap. If you are redirected to the App Store, do not download and install the app. Simply ignore it. Do not try to exit the popup by tapping the OK or Close buttons on the message.
Close the tab or the Safari window. If Safari is unresponsive, force-close the app:
If this is an iPhone X and later, swipe up to reveal the most recently used apps, and if you have a Home button, double press the Home button to open the most recently used apps, find Safari and then swipe up on Safari to close.
Now open Safari again. If the popups come back, again, close Safari. Then go to Settings > Safari and tap Clear History & Website Data. Then open Safari. You wont see the popup again.
Turn on Safari security settings:
Go to Settings > Safari and turn on Block Pop-ups. This option is listed under the General section.
Also, go to Settings > Safari and find the Privacy & Security section and turn on Fraudulent Website Warning and Prevent Cross-Site Trackin
I have had unfriendly javascript go into a loop so Safari is unresponsive.
Just quit it as mentioned above.
See also:
https://malwaretips.com/blogs/remove-your-iphone-has-been-hacked/