Hi!
I need some help with executing code in background.
It is not a location, sound, or voIP code.
I don't care if it gets rejected from the app store, i am making it for a friend.
so ya.
This is my code.
Code:
- (void)applicationDidEnterBackground:(UIApplication *)application
{
SensorAutoLockAppDelegate *appDelegate = (SensorAutoLockAppDelegate *)[[UIApplication sharedApplication] delegate];
appDelegate.on = @"ON";
if (appDelegate.on == @"ON") {
UIDevice *device = [UIDevice currentDevice];
device.proximityMonitoringEnabled = YES;
NSLog(@"Searching");
}else{
NSLog(@"Not Searching");
}
}
The below tells the app if a switch is on or off. I know it works.
Code:
SensorAutoLockAppDelegate *appDelegate = (SensorAutoLockAppDelegate *)[[UIApplication sharedApplication] delegate];
The below is turning on the proximity sensor.
Code:
UIDevice *device = [UIDevice currentDevice];
device.proximityMonitoringEnabled = YES;
NSLog(@"Searching");
}else{
NSLog(@"Not Searching");
}
This app just puts the device into sleep mode when you put it into your pocket