1. AppDelegate.swift
//post notification.
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "PushReceived"), object: nil, userInfo: userInfo)
2. ViewController.swift
override func viewDidLoad() {
super.viewDidLoad()
//add observer for load request in webview when receive remote notification.
//NotificationCenter.default.addObserver(self, selector:Selector("PushReceiver:"), name: NSNotification.Name(rawValue: "PushReceived"), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(PushReceiver), name: NSNotification.Name(rawValue: "PushReceived"), object: nil)
}
//When post notification then below method is called.
@objc func PushReceiver(notifi: NSNotification)
{
let dicNotifi: [AnyHashable : Any] = notifi.userInfo!
NSLog("notificiation Info %@ \n", dicNotifi)
if let url = dicNotifi["url"] {
self.webView!.load(URLRequest(url: URL(string: url)!))
}
}