AppDelegate.swift
var vc = ViewController()
..
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> void) {
if let pushUrl = userInfo[AnyHashable("pushUrl")] {
let pushUrlStr = pushUrl as! String
vc.changeWebviewURL(url: pushUrlStr)
}
completionHandler(UIBackgroundFetchResult.newData)
}
}
ViewController.swift
@IBOutlet weak var webVeiw: UIWebview!
..
func changeWebviewURL(url: String) {
print("changeWebviewURL : \(url)")
let request = URLRequest(url: URL(string: url)!)
webView?.loadRequest(request)
}
推送通知功能正常,“changeWebViewURL”肯定会被调用。 但是为什么没有Webview响应呢?网址没有改变。