I don't know how you have been doing your code, but when the user put the app in background you can use this method in AppDelegate.m to know the exact moment:
- (void)applicationDidEnterBackground:(UIApplication *)application {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
NSLog(@"going to background");
}
Inside of the method you can set your music to stop and set all the NSTIMERS. And you can use this one:
- (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
NSLog(@"Back from Foreground");
}
To know when the user come back from the background to the foreground.