1

Is it technically possible to send commands/events to other apps on iOS? Is there something like a system bus on iOS? Specifically, I'm interested in triggering the release button of the camera app, while open/running in order to take a shot. My thought was, maybe it's possible to generate the event that is sent whenever the user presses the -/+ buttons on the headset, for example, which also releases the camera.

UPDATE:

I'm not trying to build my own camera app. What I'm trying to accomplish is to trigger the camera app from a background service/daemon. So assume the iOS built-in camera app is running. Can a background service/daemon send commands/events to another app? Or is there some sort of "magic" system wide event that would trigger the camera?

UPDATE:

I found this question, where the event codes from the remote are read. Is it possible to send those to the system?

Any hint appreciated.

mefiX
  • 1,702
  • 3
  • 24
  • 39

2 Answers2

2

Does this help?

It basically boils down to adding Xam.Plugin.Media nuget, and then:

private async void CameraButton_Clicked(object sender, EventArgs e)
{
    var photo = await Plugin.Media.CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions() { });

    if (photo != null)
        PhotoImage.Source = ImageSource.FromStream(() => { return photo.GetStream(); });
}
Neil
  • 11,059
  • 3
  • 31
  • 56
  • Thanks, but I'm not trying to build my own camera app, I'm trying to remotely trigger/command the in-built camera app from a background service/daemon. – mefiX Mar 06 '19 at 16:37
2

You cannot really open the Camera application from within your own app. However using the answer of @Neil you can take pictures inside your own app. (without actually using the iOS camera app).

You can open other applications using (custom) URL schemes and Deep Linking. You can also send parameters along with the URL to trigger specific actions in the app you are linking to. For example:

twitter://user?screen_name=[id]

More info about this topic:

Deep Linking Xamarin iOS

Deep Linking Native iOS

Too bad, iOS doesn't provide an URL scheme for the default camera app.

DenseCrab
  • 1,273
  • 11
  • 22
  • Let's assume the camera app is already open and running. Is it possible to trigger the shutter release button in that case? – mefiX Mar 06 '19 at 16:36
  • @mefiX No, that's not how it works. You don't control other apps. You use the SDK that those apps use or you launch the app if it supports it. – valdetero Mar 06 '19 at 17:50
  • Yes, I understand that. Forget about control for a second. I'm trying to provoke the running camera app to release. I already know that the camera app will release whenever I press the play/pause button on the headphones, for example. I presume that there are events "going on" in the bg in order for that to work. Maybe there's a way to create and send one of those events myself. Something like `UIEventSubtype.RemoteControlPlay` (https://github.com/martijn00/XamarinMediaManager) – mefiX Mar 06 '19 at 18:47