Starting with iOS 12, you will always have to unlock your iPhone or iPad to connect a USB accessory. This is because of “USB Restricted Mode,” which protects your iPhone or iPad from hacking tools like GrayKey.
Starting with iOS 11.4.1, if you use USB accessories with your iPhone, iPad, or iPod touch, or if you connect your device to a Mac or PC, you might need to unlock your device for it to recognize and use the accessory. Your accessory then remains connected, even if your device is subsequently locked.
If you don’t first unlock your password-protected iOS device—or you haven’t unlocked and connected it to a USB accessory within the past hour—your iOS device won’t communicate with the accessory or computer, and in some cases, it might not charge. You might also see an alert asking you to unlock your device to use accessories.
If the USB accessory is still not recognized after you unlock your device, disconnect your device from the accessory, unlock your device, and then reconnect the accessory.
Your iPhone, iPad, or iPod touch charges as usual when it’s connected to a USB power adapter.