我有一些UILocalNotification聲音的問題。我在應用程序委託中擁有用戶權限。UILocalNotification聲音不工作
這是我的代碼:
var nottypes:UIUserNotificationType = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound
var notsettings:UIUserNotificationSettings = UIUserNotificationSettings(forTypes: nottypes, categories: nil)
application.registerUserNotificationSettings(notsettings)
代碼通知:
var notification:UILocalNotification = UILocalNotification()
notification.alertBody = "Simple"
notification.alertTitle = "Back To App!"
notification.fireDate = NSDate(timeIntervalSinceNow: 20)
notification.soundName = "Chord"
UIApplication.sharedApplication().scheduleLocalNotification(notification)
切記不要使用完整的文件路徑,包括包本身的路徑。即不要使用NSBundle.mainBundle()。pathForResource(fileName,ofType:「caf」) –