Trigger camera shutter on iPhone from Macbook - ios

I'm writing a script on my macbook to trigger the camera shutter on my iPhone.
I'm struggling to understand how to do this programmatically. I've tried:
Using macbook as bluetooth keyboard (don't know how to simulate a volume press)
Using "Switch Control" functionality on Macbook to control the iPhone device (unfortunately it seems like the simulated keypresses don't get sent over to the iPhone)
Any other ideas would be greatly appreciated !

You're close! While a bit of a kluge, you can connect a Bluetooth keyboard to your phone, enable Switch Control on iOS, and bind a key to the "Increase Volume" action. If that doesn't work, you can always bind keys to the "Move to Next Item" and "Select Item" actions, and then then move through the interface one element at a time until you reach the shutter button.

Related

Would it be possible to use the pause/play button on bluetooth headset to interact with python code on pythonista (iphone 6s)

I would like to make a script that I can press the pause/play on my Bluetooth headset (Samsung Galaxy Buds, if that helps), and when I press the button I would like it to run a function on my script.
Would anyone know how I would be able to do this, I have looked into the BC module on Pythonista but it only looks to work with Low energy Bluetooth
I am assuming the button is just a key, so I was thinking that I could design the script that so when that button is pressed it gets recognized but I have no clue how to do that on IOS.
Thanks in Advance, Jayden

Get input of switch control via headphone jack on iOS

As a little holiday project I want to control an app via an accessibility switch which is connected via 3,5mm headphone jack to the iOS device.
This is the switch and the plug:
My problem is that I don't have any clue what kind of signal is fired when I press the button - I assumed that it acts similar to a headphone's remote control.
Is there a way to measure the input of this or does anybody know how to get the input of the button on iOS?
Your button is a "Big Buddy Button Switch," designed by AbleNet for persons with moderate to severe upper extremity and motor disabilities. It is not designed to plug into an IOS device nor into any mobile tablet or phone.
There is an "Hook + Switch" interface ($185 at this moment) that is designed to go between this button and an IOS device, allowing connection of two such buttons to the lightning connector. When connected in this way, the button press can be detected and mapped to many different kinds of IOS actions using apple accessibility settings. That's a lot of money, but since new iphones don't even have audio jacks it may end up being worth it.
A link to your button is here.
A link to the Hook+ Switch Interface is here.
A link to Apple information on accessibility switches is here.
The Big Buddy Button is a passive momentary action switch. The mono TS plug attached is connected internally to the momentary action normally open switch, so pressing the switch will short TIP to SLEEVE.
Plugging this TS plug into an ios device designed to receive a TRRS plug will short RING1 and RING2 and SLEEVE together even when the button is not pressed, which will not accomplish anything useful. Pressing the button will further short TIP to RING1 and RING2 and SLEEVE. There is no way to read such a button press from ios internals if the TS plug is plugged in directly.
If you want to hack together a solution that will work for many mobile devices (e.g., android) you can do so simply by replacing the TS plug with a TRRS plug (or wiring up an adaptor) as follows:
One of the two Big Button conductors should be connected to the SLEEVE, which carries power (for a microphone) and is the source of the voltage that is sensed internally for volume changes and switching. The other Big Button conductor should be connected to RING2, which is the ground line for both earbud channels and the microphone. Nothing should be connected to TIP or RING1.
Pressing the Big Button will momentarily short Sleeve to Ring2, which is the same as pressing the switch on an earbud cable. If you wanted to simulate a volume up or volume down command, you would connect a resistor in series with the button (220 ohms for volume down, 600 ohms for volume up).
The electrical connections for the audio jack are the same for iOS devices as for Android, but there's an extra hurdle you must get over if you want to connect up buttons and have them be detected within iOS. As part of their MFI (Made for iPod/iPhone) program, Apple uses a startup recognition chirp sequence when anything is plugged into the audio jack (or the lightning connector). Your device must have the correct chip inside it (or emulate the behavior of that chip) or else the button controls interface will be disabled when you fail to respond to the authentication request. The protocol seems to have changed over time, because aftermarket products that worked with one model of phone did not always work with another. Apple insiders have stated that the MFI chips contain a serial number that Apple can read upon connection. They say that reverse-engineered authentication works today, but that Apple could prevent it from working at any time.
If you want to design this as a product, you can apply for the MFI program here.
If you just want to build a handful of devices, you won't be able to get accepted into the MFI program. In that case you'd need to purchase the Hook + Switch interface (or something like it) or else you'd need to add a small microprocessor like an Arduino or a Teensy to emulate the authentication chirp, as David Carne did here.
If you just want to build one working button, the easiest way would be to use an existing pair of headphones that contain the necessary chip, and simply put your button wires in parallel with SLEEVE and RING2. If I were doing this I'd get a TRRS extension cord and splice the Big Buddy Button wires to the correct two wires of the extension cord. Your Big Button should work so long as a pair of apple-certified headphones are plugged into the extension to provide the authentication. You would then detect the button press as usual (described here).
EDIT: I tested connecting an accessory button to SLEEVE and RING2 of a TRRS extension cable that's plugged into the iPhone, and as long as a functioning headset is
plugged into the extension cable, the accessory button does work. This way the
accessory button ends up in parallel to the built-in button, without
having to cut apart the headset.
There are other alternatives you could pursue. For example, you could build a circuit that transmits a mic-level tone across the two conductors whenever the button is pressed. You'd then plug that signal into the iOS device between SLEEVE and RING2, and then write an iOS program to listen for the sound and treat it as a button press. MFI authentication would not be needed for this approach, and there are existing utilities that would get you 90% of the way there. You can find an example here.
It's also possible to connect to iOS through BLE without signing up for MFI, and since Apple Accessibility includes the ability to use a bluetooth device to control certain iOS functions, you may be able to do this without needing authentication.
An image showing the connection schematic for TRRS connectors on most mobile devices (including iPhone) is here.
Reproduced here for convenience.
Function/Mic == SLEEVE
Common/Gnd == RING2
Right/R+ == RING1
Left/L+ == TIP
If it was as headphone jack, you can handle it using
override func remoteControlReceived(with event: UIEvent?) {}
and toggle inside of it event?.type.subType something like this.
override func remoteControlReceived(with event: UIEvent?) {
if let e = event , e.type == .remoteControl {
if e.subtype == UIEventSubtype.remoteControlPause {
// do something
}else if(e.subtype == .remoteControlPlay){
//do something else
}else if(e.subtype == .remoteControlTogglePlayPause){
// do something else
}
}
}
Apples wired 3.5 mm headphone with volume control have 4 conductors. In your picture I see only 2 conductors. So your switch can't be sending the Apples's own headphone remote commands - since the the microphone ring for sending data is missing.
I'd guess your switch just makes contact between the two conductors.
Here is what I would do.
Verify with a multi meter the resistance of your switch in the open and closed position.
I'd expect on close the resistance is low or close to zero.
Now find an (old) pair of Apple 3.5 mm headphones with volume control. Disassemble the volume control of the headphones and solder your accessibility switch to the volume control pads. Now your accessibility switch simulates pushing the volume control.
Alternatively look at http://david.carne.ca/shuffle_hax/shuffle_remote.html
So use a micro controller to simulate the headphone volume control and use your accessibility switch to control the micro controller. It looks like a fun project - enjoy.

"CBCentralManager(delegate: self, queue: nil)" does not show Bluetooth popup message when Bluetooth is turned off from Control Center

I am trying to navigate the user to Bluetooth settings on a button click. CBCentralManager(delegate: self, queue: nil) works fine when Bluetooth is turned off from Settings App, but it is not working when Bluetooth is turned off from Control center e.g not showing the default Bluetooth popup.
Now I need to know if Bluetooth is turned off from the Control center so that I can show some custom popup message to the user.
Any help will be appreciated.
You are correct that the initialization option CBCentralManagerOptionShowPowerAlertKey, which should display a warning if the framework is initiated when bluetooth is turned off, does in fact not work as expected if bluetooth is toggled off from the Control Center. Since iOS 11 the system will actually not turn off bluetooth if you toggle off the button in Control Center, it only disconnects currently connected devices. The only way to turn off bluetooth then is to do it from System Settings. This is documented by Apple, but to me it is extremely misleading. So I honestly don't know if the API behavior you are experiencing is a bug, or if it is expected behavior.
My suggestion is that you skip this initialization option and instead rely on the value of central.state when you get the "centralManagerDidUpdateState:" callback and then create you own popup if the value is CBManagerStatePoweredOff, which oddly enough will be the case regardless if bluetooth is turned off from System Settings or if it is toggled off from the Control Center.
If your app works in the background you may want to use a local notification instead to get your user's attention.
Not a perfect solution, but it should be more reliable.
I have filed bug report 47516284 with Apple for this problem. Here's the text of the issue I filed.
I have noticed that the system alert notifying a user that an app needs Bluetooth will show when I turn off Bluetooth using the Settings app. I can use this system alert to go directly to bluetooth settings to turn it back on. However, when I turn off Bluetooth using Control center, there is no system alert that displays. This is problematic because although I can display a custom alert to tell the user to turn on Bluetooth, there is no way to code bringing the user directly to Bluetooth settings by tapping a button for instance. I believe the functionality should be consistent no matter how the user turns off Bluetooth.

Default keyboard is not coming when Barcode Scanner Device is Connected by Bluetooth in IOS

I am facing issue with keyboard when barcode scanner device is connected using bluetooth.
Flow:
1) I have turned on Bluetooth, and connected barcode scanner device using bluetooth by entering displayed code in it to connect.
2) I am able to use scanner, but the default keyboard is not displaying even we call becomeFirstResponder.
3) When I disconnect the scanner device or turn off bluetooth connectivity then the keyboard is coming.
Note: Below is the link for the Barcode Scanner device i am using
Barcode Scanner Device Information
Anyone faced this kind of issue?
Please suggest how to fix this issue.
Thanks in Advance..!
This solution only works on Ipad. when the soft keyboard disappears just press and hold the down arrow on the bottom right of the screen and the soft keyboard will be back.
We are clear and there is no question that Bluetooth Scanner is pretending to be a Bluetooth keyboard, so iOS thinks that it does not need to show the on screen one.
For Barcode Scanner type socket mobile are now adding a feature to open the iPad onscreen keyboard. For example, the Socket CHS has a new button press option. You can check if your device have the same functionality*(It is likely to be of some help)*
Bring Up the Virtual Keyboard With a Real Keyboard can be a good idea.
When you have a Bluetooth keyboard connected to your iPad, the virtual keyboard will cease to appear. (This is a good thing.) However, what if, for some random reason, you needed that virtual keyboard? Don't unpair your Bluetooth. Just... Hit the eject key on Apple's physical keyboard. It'll bring up the virtual one.
There is another way to try to solve this, personally I tried it and it was very unstable. Taking into account that it is a kind of hack, expected unstable behavior.
This answer to a related question (https://stackoverflow.com/a/3837131/493988) has what seems like a hack based on a UITextField's inputAccessoryView.
Even the user #Kurt Arnlund in this answer mentions a external app called KeysPlease link here. I really have not tried it, you can try.
In summary, there seems to be a clean way to solve this, I think these may be the best attempts to reach a solution
Sources:
Bluetooth Scanner sets system-wide keyboard, UITextFields wont show soft keyboard on responder
Force on screen keyboard to show when bluetooth keyboard connected
Show iPhone soft keyboard even though a hardware keyboard is connected

Show virtual Keyboard when bluetooth keyboard connected?

I am building system for my company that use of a bluetooth RFID reader.
The problem is we cannot show the keyboard when the reader is connecting unless we turn it off.
But I saw this video
http://www.youtube.com/watch?v=0uRlIw5H0wE&feature=related
And I know we can modify the reader to temperately show the keyboard.
(Just like the button on Apple iOS keyboard)
We can ask the provider to taylor-made the reader. So we want to add a physical button on it.
Do anyone know the keycode of that button?
Can it be done just to add a button to send a keycode event???
The button that needs to be pressed is the eject button that's on a mac keyboard. I don't know what the key code is or even if you can send it. But I do know it is the eject button.
The iOS keyboard gets hidden when a bluetooth or some other physical keyboard gets connected.
I think that the button is causing the Bluetooth HID-keyboard profile to disconnect at the scanner (which in-turn enables the iOS keyboard)
I have added details on how to show both bluetooth keyboard(using HID profile) and device virtual keyboard here I want to force keyboard on with bluetooth device please check if it helps.

Resources