If the Touch ID doesn't work when charging, it is possible that you are charging your device with a cheap, fake charger, which may prevent the Touch ID sensor from functioning properly.
Test if your device's Touch ID will work, when the device is being charged using an original Apple charger. If it does, replace the fake charger with an original one, purchased from an authorized Apple store.
If you don’t receive the email in the next 2 minutes please check your junk folder, and add [email protected] to your safe sender list.