Alarm in iOS Swift
In iOS, we don't have Alarm manager.But we will use local notification as an alarm manager.
We will play the sound as like alarm.
let notification = UILocalNotification()
notification.soundName = "alarm.mp3" // add soundfile to your project and put the name here
notification.timeZone = NSTimeZone.local
notification.userInfo = data as? [String: AnyObject] //set the notification data here and get and process in the receiving end
notification.fireDate = NsDate() // set the alarm time
UIApplication.shared.scheduleLocalNotification(notification) // fire the notification
Comments
Post a Comment