Can anyone suggest me how to set sleep time in iphone application? so that after that time iphone goes in sleep mode.
Thanks in advance.
I don't think you can do this in the current OS without getting into private API's (which will get your app rejected).
You might be able to turn off auto-lock and fake your own "unlock" swipe screen though
// turn off auto-lock
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
and then create a XIB to fake an unlock screen. Not sure how apple feels about you doing that though, I'm just speculating.
Related
I built an ios game for my cat and he's quite fond of it. However, when he touches the screen , he repeatedly invokes all kinds of gestures - notification center, pinch to home screen, swipe between apps. I have to sit next to him and "fix" the game continuously, which defeats the purpose of an automatic game. I tried disabling gestures them in preferences, but the cat still manages to get out of the app.
Is it possible to "lock an iPhone" with screen on programmatically on vanilla iOS 7, so only the home button would exit the app?
I know you have asked how to do it programmatically. However, there is already an accessibility feature for your problem.
Go to Settings > General > Accessibility. Enable Guided Access and set a password. Once it is enabled, open your app and triple-click the home button. Your cat won't be able to leave the app even by clicking the home button.
For ignoring interactions you can use following:
[[UIApplication sharedApplication] beginIgnoringInteractionEvents];
This tells the receiver to suspend the handling of touch-related events. Here receiver is the Application object.
and for enable interactions again use:
[[UIApplication sharedApplication] endIgnoringInteractionEvents];
This tells the receiver to resume the handling of touch-related events.
I'm a bit confused about multitasking. I have a timer app which I am updating for OS4. Previously you had to keep the app running for the timer to sound, I have now modified it using a LocalNotification so that is the user exits the app then they get an alert when the alarm fires. I've tested this on an iPhone 4 and all is good, it works as I expected.
I then tried it on an iPhone 3G with OS4 installed. Now I thought that multitasking wasn't supported but my alert still pops up if the user has exited the app. Does this mean that multitasking isn't supported but local notifications are? I don't really want this as it causes several problems. When I click view on the alert it just relaunches the app, it doesn't take you to the alarm screen. More importantly you can't cancel this alert and could potentially set up lots of notifications which would be annoying and confusing.
Can someone clarify that my thoughts are correct? Basically I guess I want to know how to get around this. Is there something I can do to check if multitasking is supported so I can only set the notification if it is?? A clue of what to search for would do...Thanks
Multitasking and Local Notification are two different things.
Local notifications are supported on every device running iOS4.
In order to know if the device support multitasking or not you can use that
UIDevice* device = [UIDevice currentDevice];
backgroundSupported = NO;
if ([device respondsToSelector:#selector(isMultitaskingSupported)])
backgroundSupported = [device isMultitaskingSupported];
My app needs to go to sleep and wake up after a user specified time interval. Using
[UIApplication sharedApplication].idleTimerDisabled = YES;
I'm ignoring the idle timer. For the "sleep-mode" I'm turning the view to all black and hide the status bar. Still there's the device's background-light. Is there a way to turn it off or hit a real sleep mode - and then have it wake up again still being logged in and displaying the app (without the "slide to unlock" screen)?
Thank you & kind regards
You can't change the backlight programmatically in the iPhone SDK. However, I agree, it would be a useful thing.
I'm new to iPhone SDK.
Any idea how to put the iPhone into the sleep mode from within the code (my application), as if the user has clicked the sleep/wake button?
Best regards.
Your UIApplicationDelegate will have
- (void)applicationWillResignActive:(UIApplication *)application
called when the lock button is pressed but there does not seem to be a way to trigger this from code.
I'm pretty sure this will be disallowed.
You are not permitted to make changes to the state of the device (change volume etc) which would not be expected by the user.
There is no offical way to make the iPhone or iPod go into sleep mode or to lock the screen.
You have to remember that the iPhone is not a little laptop. It is also a phone and therefor an emergency communications device. Developers are not allowed to do anything that might interfere with the users control of the phone.
I want my app (LaunchDaemon) to keep running even if user locks the iPhone. My LaunchDaemon simply check a file and if some condition is true, it displays an Alert to the User. Its working great when iPhone is on Home Screen, but it is not working when user Locks the Screen.
I want something Similar to Alarm app of iPhone which will show an Alert even if the iPhone screen is Locked.
Any suggestions on how to do this? BTW i am developing for JB iPhone.
OS powers down the device and suspends your app after about 30 seconds after screen is locked. However,
if your app is playing a sound OS will not do that. Hence what you need to do is play a silent sound in a loop.
Alright i have solved this problem too.
Here is a very good tutorial on how to prevent deep sleep of iPhone.
Prevent iPhone Deep Sleep
It took me quite sometime to made this work, as NSRunLoop was not running for me automatically.
Hope this will help someone else also.
Best of Luck !!!