【问题标题】:ios swift local notifications no soundios swift本地通知没有声音
【发布时间】:2015-10-22 17:35:45
【问题描述】:

我正在尝试使用默认声音制作常规 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()

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

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

【问题讨论】:

    标签: ios arrays uilocalnotification


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      这是一个愚蠢的错误,问题是我的手机,我换了手机,一切正常

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-12-01
        • 1970-01-01
        • 1970-01-01
        • 2015-01-14
        • 1970-01-01
        • 2017-07-05
        • 1970-01-01
        相关资源
        最近更新 更多