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
를 인쇄 여기
코드이다.
아이디어가 있으십니까?
그러면 어떻게 배너를 직접 추가 할 수 있습니까? – Haring10
"배너 추가"란 무엇을 의미합니까? 당신은 무엇을 시도/희망합니까? – matt
UIAlertController (이전 UIAlertView)에 대해 알고 있습니까? 그게 당신이 찾고있는거야? 그것은 내가 "당신이 사용자에게 경고 할 수있다"고 말할 때 말하는 의미입니다. – matt