I am creating a app in which when the app is in background and user changes the volume in iPhone app should came to know about it. Any ideas or clues?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
AudioSessionInitialize(NULL, NULL, NULL, NULL);
AudioSessionSetActive(true);
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(volumeChanged:)
name:@"AVSystemController_SystemVolumeDidChangeNotification"
object:nil];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
LoginVC *login=[[LoginVC alloc]initWithNibName:@"LoginVC" bundle:nil];
self.navigate=[[UINavigationController alloc]initWithRootViewController:login];
[self.window addSubview:navigate.view];
[login release];
[self.window makeKeyAndVisible];
return YES;
}
- (void)volumeChanged:(NSNotification *)notification
{
float volume =
[[[notification userInfo]
objectForKey:@"AVSystemController_AudioVolumeNotificationParameter"]
floatValue];
NSLog(@"chfi");
// Do stuff with volume
}
I Have Used This code But its not getting Called.