ios - Local notification sound not working -


I'm trying to create an alarm app, but when I try to create a local notification, I do not sound Could play I found this error:

[user information = (zero)} with the sound but the user has not received permission to play sound]

Here's the code:

  @Iboutlet var Set Alarm: UIDPP! @IBAction func setAlarmButton (From: AnyObject) {var dateformater = NSDateFormatter () dateformater.timeZone = NSTimeZone .defaultTimeZone () dateformater.timeStyle = NSDateFormatterStyle.ShortStyle dateformater.dateStyle = NSDateFormatterStyle.ShortStyle var Datamatistry = NSString () datetimestring = dateformater.stringFromDate (SetAlaram.date) println (datetimestring) [self .localnotification (setAlaram.date)]} function localnotification (firedate: NSDate) {var localNotification: UILocalNotification = UILocalNotification () localNotification.fireDate = firedate localNotification.alertBody = "Wake up time For "localNotification.soundName =" alarm.wav "UIApplication.sharedApplication (). ScheduleLocalNotification (localNotification)} viewDidLoad () {super.viewDidLoad (Function override) DATE1 = NSDate () setAlaram.date = DATE1}  

You will have to ask u service for permission to send local notifications in iOS 8

You can then launch applications in your AppDelegate methods

  function application (application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) - & gt; Bool {application.registerUserNotificationSettings (UIUserNotificationSettings (forTypes: .Sound | .lert | | BADGE, DEPARTURE: ZERO)) True Returns}  

Comments

Popular posts from this blog

HTML/CSS - Automatically set height width from background image? -

php - Mysql Show Process - Sleep Commands and what to do -

c - What is the address of buf (the local variable in the main function)? -