Multitasking with iPhone 3G? - iphone

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];

Related

Enable LED Torch for IOS App Alerts (Without enabling in iPhone System Settings)

So here's my problem: I have alerts come from my app fairly often. I've made it so they have a custom ring and vibration for when the alerts come. I want to be able to make their LED light flash on alerts as well.
I've set it up so that if these alerts come when the app is in the foreground, the LED flash and ring/vibrate work perfectly fine. However, if an alert comes when the app is in the background, I am only able to have the ring/vibrate work.
I don't want the user to have to enable it in the iPhone system settings to get LED flash alerts from all apps. I have used the inAppSettingsKit and added a settings preference for whether or not the user wants LED flash alerts. But even though my LED alert methods are called in the background, the LED does not actually flash. Is this because Apple does not allow you to control the LED unless your using it in the foreground? Does anyone know of a workaround?
Here's the simplest part of where I have it turned on and off. I control this with different timers and notification methods. The timers and notifications are called in the background the same way they are in the foreground, however the LED just doesn't turn on in the background.
AVCaptureDevice *torched=[AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
[torched lockForConfiguration:nil];
[torched setTorchMode:YES];
[torched setFlashMode:YES];
[torched unlockForConfiguration];
Thanks!

How to prevent app from being sent kill signal when iPhone is locked on iOS5?

I have noticed since upgrading to iOS5 that an audio app I have been developing is now sent the kill signal when pressing the sleep/lock button on iPhone or iPod Touch. When sliding to unlock, the app has been closed, and we are back at the springboard.
On iOS4 devices, when locking and unlocking, you would still be in the app.
I have been able to have the iOS5 enabled device play audio in the background by using Required background modes in info.plist for the app. Locking and unlocking while the AVAudioPlayer is playing, and the app resumes right as you would expect.
There must be a simple solution for this, or has iOS5 made it so your apps are all killed on lock no matter what?
Screen locking is not the same as the app going into background, and apps are certainly not killed when it happens in any version of iOS. Chances are that your app has a bug that causes it to crash when it receives the
- (void)applicationWillResignActive:(UIApplication *)application
message that is sent when the screen is locked. Perhaps a view is being released as it goes offscreen, causing an invalid pointer reference, etc.

Continue to read iPhone accelerometer data while screen is locked (manually)

I know this issue has been discussed before as in: Enable iPhone accelerometer while screen is locked
I tried the solution mentioned in the post, including adding the DeepSleepPreventer module, as well as enabling proximity sensor as suggested in the answer Enable iPhone accelerometer while screen is locked by adding:
UIDevice *device = [UIDevice currentDevice];
device.proximityMonitoringEnabled = YES;
However, as soon as I manually lock the screen on my iPhone touch, the accelerometer stops sending data. I'm using iOS SDK 4.3. Did I miss anything? Any help would be greatly appreciated.
It's impossible to get accelerometer events on locked ios devices via SDK

set sleep time in iphone app

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.

How to run my app even after iPhone screen locks?

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 !!!