-1

알림은 위치가 가까울 때마다 활성화되어야하지만 백그라운드에서만 작동합니다. 트리거링 이벤트는 전경과 배경에서 모두 발생합니다. 앱이 포 그라운드에있는 경우 알림 처리되지 않기 때문에위치 기반 '로컬 알림'은 '배경'에서 작동하지만 '전경'에서는 작동하지 않습니다.

- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region { 

//implement local notification: 
UIApplication *app = [UIApplication sharedApplication]; 
UILocalNotification *notification = [[UILocalNotification alloc] init]; 
[[UIApplication sharedApplication] cancelAllLocalNotifications]; 

if (notification == nil) 
    return; 
notification.fireDate = [NSDate date]; 
notification.timeZone = [NSTimeZone defaultTimeZone]; 
notification.alertBody = [selectedTask discription]; 
notification.alertAction = [selectedTask taskName]; 
notification.soundName = UILocalNotificationDefaultSoundName; 
notification.applicationIconBadgeNumber = 1; 
[app presentLocalNotificationNow:notification]; 
localNotification = nil; 

} 
+0

http://stackoverflow.com/questions/11220237/uilocalnotification-not-firing-when-the-app-is-in-working-mode을 –

+0

바로 그래서 당신은 그것을 어떻게 수정합니까? – FireSky

+0

무엇을 정확히 고쳐야합니까? application : didReceiveLocalNotification이 실행되어 사용자에게 무언가를 표시하려는 경우 거기에서 작업을 처리해야합니다. –

답변

0

은 didReceiveLocalNotification 방법 내부에서 당신은 사용자에게 경고를 표시 할 수 있습니다.

UIAlertView *alert = [[UIAlertView alloc] 
     initWithTitle: @"Something" 
     message: @"Something else you want to tell the user" 
     delegate:self 
     cancelButtonTitle:@"OK" 
     otherButtonTitles:nil]; 
[alert show];