Hello, new member here although I've been on this site for years! I have an iPhone 5 with the same problems of battery drainage, shutoff at 30+%, or sometimes it'll go to 1% and last forever before it shuts down. Steps I took to remedy this:
Called Apple support, they said it was a software issue and had me do a hard reset and then reset my network settings. This worked for a day. Problem got worse. Did a complete restore via iTunes. Didn't help a bit. Backed everything up to iTunes and iCloud. Made an appointment with the Genius bar at Apple and took the phone in. When I got there, I had about 80% battery. That being said, the Genius diagnostics were showing that the battery was fine. It testing fine would mean no battery replacement. However, the Genius was a cool guy and had me play videos for awhile to drain the battery a bit. Once the battery hit 60% or below, he ran diagnostics again and viola!! It showed a faulty battery. My Applecare+ covered the cost of the replacement with no cost to me. Moral of the story? It is NOT a software issue, it is a defective battery. Unfortunately Apple doesn't want to really acknowledge this outright. If you take your phone to Apple, make sure the battery is 40% or below (that's where most of us are experiencing the issues with the battery drainage and shut down anyway). That way, chances are when Apple runs diagnostics, it'll most likely show a battery issue, not a software issue. FYI, some lady there before me had hers replaced and paid about $84 with taxes. Hope this helps some of you out because this battery thing had me furious and frustrated!