Sometimes when I plug a cable in to charge, the iPhone says it may not work with this device. How does it know it's not an Apple cable?
Apple has a program called MFi and detects if the cable has a certified chip inside. The chip just says that it's been officially 'Made For iOS.'
This helps clear up some confusion on the topic
Apple recommends using only accessories that Apple has certified and that come with the MFi badge. Learn about the issues that counterfeit or uncertified Lightning accessories can cause and how to identify these accessories.