Can we lock a phone with iOS programatically? - ios

I need to set a timer to lock an iPhone from my app. While using the application, after 3 to 5 minutes the phone should become locked.

Short answer: You can't.
Long Answer: For the security of iOS users, Apple does not allow any application to work with important hardware matters, such as locking the iPhone or controlling the usage of other apps. If your app even attempts to do such a thing (using any method, like external APIs), your app will immediately be rejected by Apple. It is not even worth trying.

You cannot lock the screen programmatically without any private API. Even if you use a private API, your app may probably be rejected by App Store.
However you can indeed achieve by sending keyboard events from paired bluetooth hardware devices. But that means your code depends on a Bluetooth connection and I cannot think of any practice use of that. To do this with Bluetooth, click here.

Related

Limitations of programmatically setting phone calls

Is there a way of programmatically setting an app so that it lets you automatically reject all phone calls while in the app?
Thankfully this is not supported in any way. A 3rd party app has no control at a all over how a phone call is handled.
This might be possible on a jailbroken device using private APIs, but certainly not for an App Store app running on normal devices.

Is it possible to turn on/off notification from different applications on ios

I am working on an application that will allow the user to turn off cellular data or at least turn off notifications from other applications on the device, all through my application. Is this possible? (I know that in Android it possible)
Your app has absolutely no control what-so-ever of other apps, not even indirectly. The one exception is using a custom url scheme to open the app, and optionally, ask it to do something.
No, on iOS you can't even find what other apps the user has installed.
Even if you could, they are all sandboxed. You can't touch anything inside the other apps.

Understanding interaction between Apple Watch and iPhone device

I am a bit confused as when I run the Apple Watch extension App schema on the simulator I see only that the Apple Watch app gets lunched. However I am not sure what will happen with real hardware once we get our hands on the Apple Watch.
I'd like to understand the following:
Do I need to start the corresponding iPhone App on the phone before
starting the App on the Apple Watch?
If the answer to 1 is no then, can I
start an iPhone App from the App on the Apple Watch? If the answer to 2
is yes then how can I start the iPhone App in a way that is not in
the background? (I found handleWatchKitExtensionRequest can trigger
background tasks but I haven't found any documentation yet for
that - I also found the Handoff Api which allows you to resume a task on the device but I don't like that it requires an iCloud account and I am not sure how to structure an App/watch interaction without forcing the user to adopt iCloud).
Given that the Apple Watch App extension resides on the iPhone App
bundle does this mean that when you start the Apple Watch App it needs a
connection and proximity with the iPhone device? I assume that there will
be a bluetooth connection and that it won't be possible to start
some apps if the user and its watch are away from the Iphone (what's
the range?)
Many Thanks
No.
No.
Unless you are on a Wifi network recognized by both your Watch and your iPhone, they'll need to be relatively close to each other. Guessing at range is useless – a number of factors can impact the useable distance of BTLE.

iOS Private API: lock device and power off the screen

I'm making an app for jailbreak that lock the device when the user launch the app. I've tried GSEventLockDevice(); from GraphicsServices.framework but this does not work properly because it locks the screen but does not power off the screen. Is there another way to lock the screen without MobileSubstrate?
Just as another alternative, check out this answer, which uses SBDimScreen(). You could use that in conjunction with GSEventLockDevice().
It appears that you may now (iOS 5+) need to add an entitlement to your app to use this call successfully. If you haven't done that before, here is an example of how to do so. Obviously, in this case, the entitlement in question must be changed to com.apple.backboard.client.
You also might see if #VictorRonin has experimented with this, as he commented on the question I linked to. I tested SBDimScreen() on a jailbroken iOS 4.2.1 device, but my newer devices are currently unavailable to run this test. I'll try it later on iOS 5.x and post an update.
Note: the answer I linked to from Elias has a different call altogether for iOS 6.
Look at these several questions:
Simulating System Wide Touch Events on iOS
Simulating System Wide Touch Events in iOS without jailbreaking the device
How to send a touch event to iPhone OS?
The idea is that you can simulate system wide events. One of events is power down event. If you simulate it, it will turn off device and will lock it.
BTW. You may be interested to google more on GSEvent which is the key for even simulation.
Here are couple of useful links:
http://iphonedevwiki.net/index.php/GSEvent
http://networkpx.blogspot.com/2009/08/gsevent-recording-and-playback-in-30.html
Also, this approach isn't limited to jailbroken phones. It works on jailed phone too (however, you won't be able to post it to AppStore).

Controlling iOS device

Is it possible from my app to run in background, turn on/off other apps, control the iOS device without jailbreaking it? I understand that this app will not pass Apple's review/approval, but I am not planning it, instead, I just need to distribute it to clearly defined list of devices. I just prefer not to require to jailbreak device.. Is it possible?
I believe its possible without actually jailbreaking the physical device. Check out the second answer to this question for some more information. iOS app without developer program or jailbreak

Resources