Mahesh
Mahesh

Reputation: 996

Is it possible to flash a flashlight in iPhone when application is background mode?

Is it possible to flash a flashlight in iPhone when application is background mode? Please give some suitable suggestion.

Upvotes: 6

Views: 2931

Answers (4)

Dinesh sharma
Dinesh sharma

Reputation: 31

Already given the answer similar of your this question, pls see this link at once

Iphone flashlight not working while app is in background

This is a normal behavior. Apple's sandboxing will not allow you to keep the flash on while your app is in the background. There is no workaround unless we are talking about a jailbroken app.

Edit: Apple is very strict on it's system's APIs usage. Especially when it comes to: - User privacy - Battery life - User experience

In the case of the flashlight, the last two items are relevant. Apple will not let an app drain the battery when not in the foreground and iOS users are used to the fact that flashlight, camera, microphone... are immediately disabled when going to the background (with an exception for the microphone in some background modes cases).

To answer the comment on your initial post, iOS controls your hardware. So since Apple decided they don't want the light to stay on when the user closes the app, iOS will just power off the flash when your app goes in the background. Your app has no authority to prevent it.

Upvotes: 3

Sanjay Chaudhry
Sanjay Chaudhry

Reputation: 3181

My app is an audio player, so it keeps running in the background. But flashlight works only when it's in the Foreground. No flashlight from the background.

Upvotes: 1

donald
donald

Reputation: 489

When in background your application doesn't work or get any messages from the system. The only cases when this is allowed are:

  1. navigation application
  2. audio player
  3. Internet telephony

Unless you are designing any of the above you can not flash the user with anything. If you only want to notify the user about something, you can create a notifier that will pop a message in the users window even if your application is in the background or entirely off. the user can click the message and then he will be back to your application

Upvotes: 1

Harikrishnan
Harikrishnan

Reputation: 9979

try AVCaptureDevice

AVCaptureDevice

Upvotes: 0

Related Questions