My XS max used to switch off when the charging pin was connected and switch on again after the pin was disconnected. If the phone got heated up, the charging % was very less.. I had switched to charging by a wireless charger for the last 6 months.
after the recent update to iOS 17.1, wireless charging also failed.. I took the phone to a local unofficial Apple service who diagnosed the problem was due to charging port. He replaced the port and the phone is now charging well, like before 😀 whew!