Can I programmatically lock my iphone screen? - iphone

I am working on a jailbroken iphone and I don't care if Apple rejects this app.
I am not talking about the simple keypad lock that can be achieved through
GSEventLockDevice();
I am talking about a passcode lock or some way to get the iphone stuck or to disable the home button?
Is it possible programmatically?

It's called kiosk mode or guided mode.
Here are couple of articles generally describing this subject:
http://joris.kluivers.nl/blog/2012/03/02/kiosk-mode-for-ios/
http://www.idownloadblog.com/2012/06/26/ios-6-guided-access/
Here is stackoverflow question with several approaches:
Lock-down iPhone/iPod/iPad so it can only run one app
And here is one more approach:
https://blog.compeople.eu/apps/?p=275

Related

Executing code of app without opening view for user

I want to execute code on background, when user clicks on app icon? Is it possible? I want to turn bluetooth when I click on app icon on Iphone. Thanks a lot !
As per this answer, there is no way to turn on Bluetooth without Apple rejecting your app. Therefore, the best way to have the user turn on Bluetooth is to tell the user to do so(e.g. through an alert/popup).
As for executing code in the background, check out this answer, which describes how threading works in Swift.

Assigning app functionality to silent/mute switch in iOS

Is it possible to programmatically link the physical mute/silent switch to an app function?
I would like to use the mute/silent switch as a toggle to lock/unlock aspects of an app (not sound-specific, but the app does not rely on audio so mute or not is actually moot. ;)
I think you can do that by capturing the hardware button call back; capturing the callback is explained by #John Fricker here.
But the app may be rejected by apple 'cos as per app store review guidelines
10.5 Apps that alter the functions of standard switches, such as the Volume Up/Down and Ring/Silent switches, will be rejected
No, it is only for Lock Rotation or Mute. You can choose it in Settings app.
but it seems to be possible to detect the state of the mute switch.
How to programmatically sense the iPhone mute switch?
This can be done, an app That does this will not be rejected by Apple because first, there's already two apps on the AppStore does this. Second the appstore review guidlines say that you cannot alter the standard function, but we are not trying to alter the finction, we are using the same function.

Device auto-lock

I have an application in which I want to lock the iPhone programmatically so that the user can't perform any action.
How can I determine the user is not working with the iPhone for some period, and after that period automatically lock the phone?
Such applications are used in all phone devices, where the user can set an auto-lock time and then the device will automatically lock if the user does not handle the device.
How is it done programmatically? Please give me one example of the code so I can perform this easily.
I am new to iPhone programming, and I am struggling in my application. Help me. Thanks in advance.
(For your lock the iphone device through programatic only )
Impossible.
But , you could prevent your phone from locking when your app is running.
[UIApplication sharedApplication].idleTimerDisabled = YES
There is no way to disable the Home Button in iOS using the documented API. The user will always be able to get back to the home screen or close your application using the Home Button.
Even if you find a way do it (which is very unlikely) your app will be definitely rejected from the App Store for a blatant violation of the iOS Human Interface Guidelines. If I were you I would reconsider implementing this behaviour, frankly, it's just not a good idea.
If you're only looking for blocking the the UI of your app, check out the answers to this question, more specifically, check out the incredibly useful MBProgressHUD library:

iPhone locked in portrait mode

My question is similar to this thread
which says to lock the iPhone in portrait mode and doesnot allow it to go to landscape mode.
This can be done easily but my concern is I want to lock all the applications running to the portrait mode in iOS 4.
That is if I have locked the orientation mode and has minimised my application then the none of the application in iPhone shall go to landscape mode.
So my question is
Is it possible
if yes then how? Any ideas or link will be really appreciated.
Edit: I know this is already available in iOs 4.0 but its hard to find also this is just for information purpose.
For those who disagree: check out the link
Thanks in advance...
Edit: Finally as per everyones suggestion I think it is not at all possible to lock other applications orientation through our application.
How would you feel if any 3rd application is accesing the orientation of your application and that of device.
So Its all handled out by Apple itself. Also as told no application is allowed to effect the system variable..
So in case you succeed in finding out the hack for this thing... Then also your application is gonna rejected by apple...
Still all the best for ur research :P
Sorry, but you can't lock the orientation via public APIs, and if you are going to use private APIs, Apple will never approve your app.
An iPhone app cant affect system wide variables such as screen lock. If you could, then there would be nothing keeping you from accessing all the other data on the device as well. Sorry, but if you want your app approved by Apple, you'll have to give up on this feature.

How to render the iphone device screens on mac OS or in windows

We have an iphone device in our company and for the remote demo purpose I have to show some of the device specific features like voice call, accelerometer etc. (which is not possible on a iphone simulator), from a mac / windows system. Is there any way to render the device screens on mac /windows machine?
Advance Thanks,
Sathish
I have not tried this but there is a private API MPTVOutWindow which can be used. For details on how look at this blog post http://www.touchcentric.com/blog/archives/3
As this is a private API, it needs to be built into your app and it will never pass the app store submission process whilst it is in the app.
An easier way would be to set up a web cam overhead above the phone.
You can take a screenshot by pressing both hardware buttons simultaneously (power at the top and home at the bottom). You can then mail the images or sync to get them onto the computer. If you need to show the application in action, not just static screens, you could separate the assets and animate in Flash.
Apple does this with iPhones at their keynote speeches and at WWDC all the time. However, it seems that they have "special" iPhones; some presenters use the camera-over-the-iPhone approach and some have direct iPhone-to-video connections. Regardless, this is not currently possible on an iPhone that you haven't jailbroken. Your best bet is to simulate it.