2014-10-31 2 views
0

remote and local notifications이 내 앱에 허용됩니다. remote notifications에 대해 완벽하게 작동하지만 local notifications을 사용하려고 시도하면 알림이 표시되지 않지만 코드가 실행 중입니다.UILocalNotification은 표시 권한이 필요하지만 이미 부여되었습니다.

앱에서 나가면 원격 알림이 작동하지만 앱에있을 때 로컬 알림을 표시하지 않으시겠습니까? didFinishLaunchingWithOptions 방법에

:

let notificationTypes:UIUserNotificationType = UIUserNotificationType.Badge | UIUserNotificationType.Sound | UIUserNotificationType.Alert 
let notificationSettings:UIUserNotificationSettings = UIUserNotificationSettings(forTypes: notificationTypes, categories: nil) 
UIApplication.sharedApplication().registerUserNotificationSettings(notificationSettings) 
UIApplication.sharedApplication().registerForRemoteNotifications() 

및 상기 통지의 수신 :

if(application.applicationState == UIApplicationState.Active) { 
     var ln: UILocalNotification = UILocalNotification() 
     ln.userInfo = userInfo 
     ln.soundName = UILocalNotificationDefaultSoundName 
     ln.alertBody = notification["alert"] as NSString 
     ln.fireDate = NSDate() 
     application.scheduleLocalNotification(ln) 
     println("local") 
    } else { 
     PFPush.handlePush(userInfo) 
    } 

앱, 그것은 local를 인쇄 여기

코드이다.

아이디어가 있으십니까?

답변

1

로컬 알림이 무엇인지 알 수없는 것 같습니다. 로컬 알림의 요점은 앱이 가장 앞에 있지 않을 때 시스템이 사용자를 대신하여 사용자에게 알릴 수있는 방법이라는 것입니다. 앱 이 가장 앞에있는 경우 일 경우 시스템에서 더 이상 수행 할 작업이 없습니다. 따라서 로컬 알림은 앱이 맨 앞에있을 때 사용자에게 경고를 발생시키지 않습니다. 대신 앱이 가장 먼저 알림을 받으면 앱에 알리고 으로 사용자에게 알릴 수 있습니다.

+0

그러면 어떻게 배너를 직접 추가 할 수 있습니까? – Haring10

+0

"배너 추가"란 무엇을 의미합니까? 당신은 무엇을 시도/희망합니까? – matt

+0

UIAlertController (이전 UIAlertView)에 대해 알고 있습니까? 그게 당신이 찾고있는거야? 그것은 내가 "당신이 사용자에게 경고 할 수있다"고 말할 때 말하는 의미입니다. – matt

관련 문제