When ever load a browser inside of application. Apple is preferred SafariServices.
This class will help to load a url from anywhere in your project. like from ViewController or any NSObject class.
So, that I have created a class to call a SafariViewController.
// For handling tap and user actions
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
if response.notification.request.content.categoryIdentifier == "NotificationServiceCategory" {
if response.notification.request.identifier == "localNotification" {
// let _ = response.notification.request.content.userInfo
} else {
// Do something.
}
} else {
// Do something.
}
}
//for displaying notification when app is in foreground
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
//If you don't want to show notification when app is open, do something here else and make a return here.
//Even you you don't implement this delegate method, you will not see the notification on the specified controller. So, you have to implement this delegate and make sure the below line execute. i.e. completionHandler.
completionHandler([.alert, .badge, .sound])
}
}