Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can i check to see if the iPhone is docked?

I wish for my app to act differently when the phone is docked or otherwise connected to the computer. Is this possible?

like image 635
Andrew Avatar asked Jan 28 '11 19:01

Andrew


People also ask

How do I stop my iPhone from sharing other devices?

Turn off Handoff on your devices iPad, iPhone, and iPod touch: Go to Settings > General > AirPlay & Handoff. Mac: Choose Apple menu > System Preferences, click General, then deselect “Allow Handoff between this Mac and your iCloud devices.”

How do I view my Dock?

Open the Watch app on your iPhone. Tap the My Watch tab, then tap Dock.


1 Answers

I couldn't find anything offhand about whether it's docked, but if you look at the UIDevice class you'll find the batteryState property. If you enable battery monitoring in your app, you can check to see if the property is set to UIDeviceBatteryStateUnplugged, implying the device isn't docked. If it's another value (UIDeviceBatteryStateCharging or UIDeviceBatteryStateFull), the phone is connected to power.

Note this doesn't guarantee there's a computer at the other end; it could just as easily be a power adapter into a wall or other USB-powered device.

like image 195
Tim Avatar answered Oct 04 '22 07:10

Tim