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
UserData - You can send the data as a dictionary formats with key values to the user app and based on the data you can navigate the user inside the app.

    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

    Popular posts from this blog

    Invalid bundle error while upload the app to the app Store

    Convert NsNumber, NSDate to String in iOS Swift

    Global LocationManager Singleton class iOS Swift