저는 iOS 개발의 초보자입니다. 저는 현재 대학 프로젝트에 배터리 유틸리티 앱을 개발 중입니다. 내 설정 열에는 배터리가 완전히 충전되었을 때 알림을 수신할지 여부를 사용자가 켜거나 끄도록 할 수있는 옵션이 있습니다. 스위치가 켜져있을 때 로컬 알림을받는 문제가 있습니다. 배터리 수준 == 1.0 일 때 스위치를 끄고 다시 켜려고 할 때만 알림을 볼 수 있습니다. 누군가가 나를 도울 수 있다면 정말 고맙습니다. (무효)가 notifyFullyCharged {UISwitch가 켜져있을 때 지역 알림을받는 방법?
float batterylevel = [UIDevice currentDevice].batteryLevel;
if(batterylevel == 1.0){
// Schedule the notification
UILocalNotification* localNotification = [[UILocalNotification alloc] init];
//localNotification.fireDate = pickerDate;
localNotification.alertBody = @"Unplug your device. Your battery has been fully charged.";
localNotification.alertAction = @"Slide to view";
localNotification.timeZone = [NSTimeZone defaultTimeZone];
localNotification.applicationIconBadgeNumber = [[UIApplication sharedApplication] applicationIconBadgeNumber] + 1;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
}
}
답변 해 주셔서 감사합니다. 이제 앱으로 돌아올 때만 알림보기를 표시하여 알림을 받았습니다. 그러나 응용 프로그램이 비활성 상태 일 때 알림 메시지를 표시 할 수 없으며 알림 센터에서 알림을받지 못했습니다. 이는 전화가 잠겨있을 때를 의미합니다. :( – user3378060