ios swift 本地通知没有声音

ios swift local notifications no sound

我正在尝试使用默认声音制作常规 UILocalNotification

这是我的功能

func makeLocalNotificationForNow(str : String , id : String)
{
let notification = UILocalNotification()


notification.alertBody = str // text that will be displayed in the notification
notification.alertAction = "open" // text that is displayed after "slide to..." on the lock screen - defaults to "slide to view"
notification.fireDate = NSDate(timeIntervalSinceNow: 5) // todo item due date (when notification will be fired)
notification.soundName = UILocalNotificationDefaultSoundName // play default sound
UIApplication.sharedApplication().scheduleLocalNotification(notification)
}

在我的 didFinishLaunchingWithOptions 函数中我输入了

let settings = UIUserNotificationSettings(forTypes: [.Alert, .Badge , .Sound], categories: nil)
            application.registerUserNotificationSettings(settings)
            application.registerForRemoteNotifications()

注意:我也使用解析推送通知

当我发出通知时,它出现但没有提示或声音(我需要从顶部滑动才能看到通知 怎么了?!

据我所知,通知仅在应用程序处于后台时发出声音,这意味着退出您的应用程序,将您的 phone 置于锁定模式并通过解析网站发送通知,然后您应该听到声音,如果没有,请检查您正在制作的应用程序上的设置,看看是否启用了声音警报,最后一个资源,检查您的 phone 是否仅振动

这是一个愚蠢的错误,问题出在我的 phone 上,我更改了 phone 并且一切正常