In iOS 12 version, it requires you to unlock your iPhone/iPad if you want to connect a USB accessory. It’s because of “USB Restricted Mode” option, which can protect your iPhone/iPad from hacking tools.
Why You’re Seeing This Message
You will see this message due to “USB Restricted Mode,” which is a security feature added from iOS 11.4.1 version and improved on in iOS 12. With this feature, any USB devices from setting up a data connection will be prevented while your iOS device is locked. Devices connected to the Lightning port can still charge your iPhone/iPad and they are not able to do anything until you unlock it.
To prevent the exploit, Apple will restrict USB devices from setting up data connection when your iPhone/iPad is unlocked. Although that’s the default setting, you can turn off this security feature in Settings. But we don’t recommend you to do it. USB Restricted Mode will prevent other people from accessing to your IOS device without permission.
When connecting a USB device to your iPhone/iPad while the restricted mode is enabled, there will be a “USB Accessory” notification, saying “Unlock iPhone/iPad to use accessories”.
iOS 12 Removes One Hour Grace Period
Apple added “USB Restricted Mode” feature from iOS 11.4.1 version. But in the original state, there is a one-hour grace period. Any USB device will be able to set up a connection as long as your iPhone/ iPad is unlocked in the last hour. Once a device was connected, the timer would then be reset.
Anyone who got their hands on your device would need to plug any old USB device into your phone’s port within one hour after the last time you use it in order to bypass this protection. Apple added the one hour grace period so that this protection is less annoying.
From iOS 12 beta version, Apple seems to remove this grace period. When your iPhone or iPad is locked and you plug in an accessory to your phone, you will be prompted to unlock it. If you have USB Restricted Mode enabled, your iPhone/iPad will be protected.
How to Disable USB Restricted Mode
We don’t recommend you to turn off USB restricted mode. When you connect a USB accessory, you will have to unlock your phone, which can be done easily and quickly with Touch ID or Face ID.
However, if this feature is quite annoying, you can disable it. Perhaps you use many USB accessories and you feel it annoying to unlock your iOS device each time. It’s up to you.
To turn off USB Restricted Mode and allow USB accessories function even when your phone is locked, simply navigate to Settings > Touch ID & Passcode (or Face ID & Passcode on iPhone X) and enter your PIN to continue the process.
From the “Allow Access When Locked” section, toggle the switch next to “USB Accessories” option to on. Once this option is enabled, other devices will be able to connect to your iPhone/ iPad even while it’s locked.
Again, it’d better enable this feature since it can protect your private data from hacking tools currently being used worldwide.