UILocalNotification in swift3
You can create a common method to trigger LocalNotification in swift.In that, You can pass the parameters fireDate, NotificationTitle, User data.fireDate - Which time the notification wants to be Triggered.Notification Title - You can send the title what you want to be shown to the user
Code:
func showNotification(detail:String,day:NSDate,Sound:Bool,notificationData:NSDictionary) {
let notification = UILocalNotification()
notification.timeZone = NSTimeZone.local
notification.userInfo = notificationData as? [String: AnyObject]
notification.alertBody = detail
notification.alertAction = "open"
notification.fireDate = firedate as Date
if Sound {
notification.soundName = "sound.mp3"
}
UIApplication.shared.scheduleLocalNotification(notification)
}
Comments
Post a Comment