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
。
任何想法?
那你怎麼能自己添加一個橫幅? – Haring10 2014-10-31 19:27:24
「添加橫幅」是什麼意思?你在做什麼/希望做什麼? – matt 2014-10-31 19:37:41
你知道UIAlertController(舊的UIAlertView)嗎?那是你在找什麼?當我說「你可以提醒用戶」時,這就是我的意思。 – matt 2014-10-31 19:40:15