2015-10-22 151 views
0

蔭試圖與默認的聲音有規律UILocalNotificationIOS迅速本地通知沒有聲音

這是我的功能

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() 

:我也使用解析推送通知

當我進行通知它似乎沒有警報或聲音(我需要從頂部滑動看到通知 有什麼問題?!

回答

0

這是一個愚蠢的錯誤,問題是我的電話,我改變了手機,這一切工作

0

據我所知,通知只會在應用程序處於後臺時發出聲音,意味着退出應用程序,將手機置於鎖定模式並通過解析網站發送通知,然後您應該會聽到聲音,如果不,請檢查你正在做,看看聲音警報啓用應用程序,並最後一個資源的設置,檢查您的手機上沒有隻振動