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