iPhone won’t charge, stopped charging or if you see an alert message saying “this accessory may not be supported“? There are various reasons that can cause iPhone charging problems, or the ‘Accessory may not be supported’ alert, the accessory is defective, damaged, or not Apple-certified, iPhone Lightning port or charger is dirty, damaged, or broken, etc. See these iOS devices won’t charge solutions for more details.
Sometimes my phone charges, sometimes not or it stops charging suddenly. Occasionally it throws an alert message “this accessory may not be supported“. Double checked the Lightning connector for my iPhone 8 which features 8 symmetrical pins on either side of the connector, I found 4th pin turns from golden color to black. So I cleared the lightning port’s 4th pin which has turned black with tweezers and eraser gently. And it seems to fix the iPhone won’t charge, stopped charging problems. And the “this accessory may not be supported” error doesn’t come back again.

Note that each pin has its own function. For example, the first and fifth pins are used to detect and recognize the connected accessories; the second, third, sixth, seventh for data exchange; the forth pin is designed for phone charging.
If you run into the same problem, and found the 4th pin or 5th depending on which side you are counting from is eroded or oxidized and thus becomes black, try to clear it with alcohol, dry clean duster, eraser or tweezers see if any luck.