2016-12-06 1 views
2

아래 코드를 사용하여 알림을 생성하고 있지만 어떻게 든 실행되지는 않습니다. 하나의 특정보기 컨트롤러를 열 때 실제로 트리거하기를 원하지만 지금까지는 아무 것도 실행되지 않습니다. 내 코드의 문제점은 무엇입니까?UILocalNotification이 작동하지 않습니다.

func notify() { 
    let notification = UILocalNotification() 
    notification.fireDate = Date() 
    notification.repeatInterval = .minute 
    notification.alertBody = "The alert body" 
    notification.alertAction = "enter text here" 
    UIApplication.shared.scheduleLocalNotification(notification) 
} 
나는 또한 애플 대리자에서이 라인이

: notification.fireDate = Date()에 의해 과거에있을 것입니다 현재 시간에 fireDate을 설정 때문에

나는이 실패 믿고
application.registerUserNotificationSettings(UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)) 

답변

1

한 이유입니다 알림을 시작하려는 UserNotifications를 관리하는 (별도의) 프로세스에 경고가 표시되는 시간입니다. UNNotification s로 이동하는 것을 고려하십시오

+0

이것은 그 것이었다! 나중에 날짜를 조금 변경하면 다시 작동하여 알림을 보냈습니다. – Misha

0

나중에 발사 날짜를 특정 시간으로 변경했습니다 (오후 6시에 calendarComponents를 사용하여 06:03으로 변경 한 후 작동하는 것처럼 보였습니다.)

관련 문제