2014-01-10 2 views
1

내 전화를 켜고 특정 지역 안에있을 때마다 로컬 알림을 시작하려고합니다. 예상대로 작동하지만 기기를 켤 때마다 새로운 알림이 표시됩니다. 기존 알림을 그냥 남겨두면 알림 목록의 맨 아래로 밀어 넣을 수 있습니다. 기존 알림을 취소하고 새 알림을 만들면 이상한 애니메이션이 표시됩니다.CLBeaconRegion notifyEntryStateOnDisplay 및 UILocalNotifications

  1. 이미 전달 된 기존 UILocalNotification을 업데이트하여 맨 위로 밀어 넣습니다.
  2. 잠금 화면이 사라지고 알림을 취소하면 어떻게 되나요? 여기

는 기존 코드입니다, 난 당신이 목록을보고

- (void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region { 
    if ([region isKindOfClass:[CLBeaconRegion class]]) { 
     CLBeaconRegion *beaconRegion = (CLBeaconRegion*)region; 
     UILocalNotification *existingNotification = self.beaconNotification; 
     switch (state) { 
      case CLRegionStateInside: 
       self.beaconNotification = [[UILocalNotification alloc] init]; 
       self.beaconNotification.alertBody = @"You're inside the region"; 
       [[UIApplication sharedApplication] presentLocalNotificationNow:self.beaconNotification]; 
       if (existingNotification) { 
        [[UIApplication sharedApplication] cancelLocalNotification:existingNotification]; 
       } 
       break; 
      case CLRegionStateOutside: 
       self.beaconNotification = [[UILocalNotification alloc] init]; 
       self.beaconNotification.alertBody = @"You're outside the region"; 
       [[UIApplication sharedApplication] cancelAllLocalNotifications]; 
       break; 
      default: 
       break; 
     } 
    } 
} 

답변

0

확실히 더 알림 Is there a way to check if the iOS device is locked/unlocked?

잠금 해제 휴대 전화가 잠겨있는 경우 감지 할 수있는 방법 /가 있습니다 제안 : http://iphonedevwiki.net/index.php/SpringBoard.app/Notifications 전화가 종료 될 때 호출되는 com.apple.springboard.deviceWillShutDown 알림이 포함되어 있습니다. 방금이 코드를 테스트하고 작동하는 것처럼 보이지만 응용 프로그램이 즉시 종료되고 Xcode 세션이 종료되므로 실제 응용 프로그램의 유용성이 확실하지 않습니다.

CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), 
            NULL, 
            shutdownCallback, 
            CFSTR("com.apple.springboard.deviceWillShutDown"), 
            NULL, 
            CFNotificationSuspensionBehaviorDeliverImmediately); 
void shutdownCallback (CFNotificationCenterRef center, void *observer, 
       CFStringRef name, const void *object, CFDictionaryRef userInfo) 
{ 
    NSLog(@"Shutting down"); 
} 

이상한 애니메이션을 생각하면 마음에 들지 않으면 Apple에 신고하십시오. 오직 그들은 그것을 고칠 수 있습니다. 알림을 업데이트해야한다고 생각하지 않습니다 (가능한 경우). 간단히 새로운 것을 밀어 넣고, 오래된 것을 제거하거나 그것으로 귀찮게하지 마십시오. 이것은 대부분의 응용 프로그램이하는 일이며 사용자는 일반적으로 문제가 없습니다. 그것은 일종의 역사로도 작용합니다.

+0

그래, 전화기가 잠겨 있거나 잠금이 해제되어 있는지 감지 할 수는 있지만 휴대 전화를 켜면 알림을 받고 휴대 전화를 끄면 다시 알림을받지 못합니다. –

+0

알림 문제를 완전히 이해하고 있는지 확신 할 수 없지만 답변에 좀 더 자세한 내용을 추가했습니다. 도움이되는지 알려주세요. – allprog

관련 문제