내 전화를 켜고 특정 지역 안에있을 때마다 로컬 알림을 시작하려고합니다. 예상대로 작동하지만 기기를 켤 때마다 새로운 알림이 표시됩니다. 기존 알림을 그냥 남겨두면 알림 목록의 맨 아래로 밀어 넣을 수 있습니다. 기존 알림을 취소하고 새 알림을 만들면 이상한 애니메이션이 표시됩니다.CLBeaconRegion notifyEntryStateOnDisplay 및 UILocalNotifications
- 이미 전달 된 기존 UILocalNotification을 업데이트하여 맨 위로 밀어 넣습니다.
- 잠금 화면이 사라지고 알림을 취소하면 어떻게 되나요? 여기
는 기존 코드입니다, 난 당신이 목록을보고
이- (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;
}
}
}
그래, 전화기가 잠겨 있거나 잠금이 해제되어 있는지 감지 할 수는 있지만 휴대 전화를 켜면 알림을 받고 휴대 전화를 끄면 다시 알림을받지 못합니다. –
알림 문제를 완전히 이해하고 있는지 확신 할 수 없지만 답변에 좀 더 자세한 내용을 추가했습니다. 도움이되는지 알려주세요. – allprog