how do i know when i need to replace my iphone battery?
Go to Settings > Battery and, if it's in bad enough shape, you'll see a notification at the top of that screen that says your battery needs to be serviced. Take your phone to the nearest Apple Store for a battery replacement (third-party repair shops may charge less).