Q: The rear-facing camera on my iPhone is foggy, but the front-facing camera is perfectly clear. What can I do to fix it?
A: It's fairly safe to rule out any software problem with your phone, especially since you said the front-facing camera is working properly. So, it has to be one of three causes: you either have a bad scratch or scratches on the lens of your camera or you have moisture inside your iPhone, or there is the possibility that your lens is just dirty.
Now, I am assuming that you have already tried to clean your camera lens, but even so, that's where I would start. Take a slightly damp cloth with a little bit of gentle soap on it, and rub the lens. Then, dry it off. After you're done with that, try taking a few pictures, and see if it's still not taking clear photos. If the pictures are still foggy, take the edge of your fingernail or a guitar pick, and gently scrape the lens. If any debris comes off, get that cloth back out and keep cleaning!
If that still doesn’t fix the problem, try feeling for ridges on the lens. If you find any, you have a scratched lens which is most likely your problem. Otherwise you probably have moisture in your iPhone. If moisture is the problem, there’s a simple fix you can try, although it’s a little bit unusual. Turn off your iPhone. Then, take a gallon size Ziplock baggie, and fill it with about a pound of rice. Now, take your iPhone and bury it in the bag of rice, and seal the bag. Leave it in there for a couple of days. Believe it or not, that should draw most of the moisture out of your phone. Now, take out your iPhone, turn it back on, and try to take a picture. With any luck, it will have cleared up.
If that doesn't work, it's time to take your iPhone to the Apple Store. They might not be able to do anything about it, because you may have violated your warranty, for instance if you have gotten your iPhone wet, but they'll be able to tell you what they can do, and they might do it for free. Either way, they'll be able to clearly diagnose the problem, and you can make a decision on how to handle it from there.
If the Apple store will repair it for free, that's the best, easiest solution, but if Apple won’t fix it for free you have three options: pay Apple to fix it, pay someone else to fix it, or fix it yourself. A lot of times, Apple will offer to repair your iPhone for a fee, even if you have violated the warranty. It's often a fairly hefty fee though, and they usually have to send your iPhone out for repairs.
If you're a tinkerer or just feeling adventurous, you can fix it yourself. If the problem was scratches, you'll need to replace the lens cover or possibly the entire back of the phone. There are full breakdown and repair guides on ifixit.com and directfix.com. Both sites also sell the special tools and the parts you need to take apart iPhones and repair them.
However, you are doing this at your own risk. If you aren't completely comfortable with plunging into the guts of your iPhone check out our business directory on our website, where you can find experienced, local professionals who can help! Having a third party open up your iPhone will void your warranty, but you've already worked out that option, so there's nothing to lose at this point on that front. And often, you can get your iPhone repaired for considerably cheaper than what a new one will cost you. Don’t let a bad camera lens ruin your day!