Unless your iphone has been jailbroken, no virus can attack your device.
And the message you got didn't come from Apple. Most likely it was a phishing / scam attempt.
NEVER give any personal info to anyone.
Then read this support article:--> Recognize and avoid phishing messages, phony support calls, and other scams - Apple Support
If you got that message while surfing the Internet, follow also these steps:--> Clear the history and cookies from Safari on your iPhone, iPad, or iPod touch - Apple Support
When done, restart your iPhone.
Regards
Giulio