In my app you have the option to watch a certain given area. When the boundaries are crossed a notification is given. An alertView and Sound when the app is in the foreground and a notification with the alarm sound when the app is in the background. When the app is in the foreground everything is ok. When in the background, not notification is given and no alarm sound is played. It has worked fine before. 

Here is my code:

```
// Show alertview when active and show localNotification when inactive

-(void)AlertViewShow{

    if (i == 1) {

    UIAlertView *alert = [[UIAlertView alloc]
                          initWithTitle:NSLocalizedString (@"Alert",@"")
                          message:NSLocalizedString(@"AlertMoving",@"")
                          delegate:self
                          cancelButtonTitle:NSLocalizedString(@"AlertOK",@"")
                          otherButtonTitles:nil];

    [alert show];

    NSURL *soundURL = [[NSBundle mainBundle]URLForResource: @"ALARM"
                                             withExtension:@"WAV"];
    avSound = [[AVAudioPlayer alloc] initWithContentsOfURL:soundURL error:nil];
    avSound.numberOfLoops = -1;
    [avSound play];
}
i = 2;
}

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) {
    if ([avSound isPlaying]) {
        [avSound stop];
    }
}
if (i == 2) {
    [[UIApplication sharedApplication] cancelAllLocalNotifications];

}

}

- (void)localNotification {

UILocalNotification *localNotif = [[UILocalNotification alloc] init];

if (localNotif == nil)
    return;
localNotif.fireDate = nil;
localNotif.alertBody = NSLocalizedString (@"NotifAlert",@"");
localNotif.alertAction = NSLocalizedString (@"NotifView",@"");
localNotif.soundName = @"ALARMSHORT.wav";
localNotif.applicationIconBadgeNumber = 0;

[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];

}

// END Show alertview when active and show localNotification when inactive 

```

Does anyone know what is changed so why it is suddenly not working anymore?
Appreciate your help.