我的 ViewController 中有一个 UIWebView
。我需要在收到推送通知时将其重定向到特定页面,接收推送通知的方法在 AppDelegate
中。
那么我如何从 AppDelegate
访问 ViewController 中的 UIWebView
?
最佳答案
你可以使用 nsnotification 观察者
当收到推送通知时,您可以发布如下通知
[[NSNotificationCenter defaultCenter] postNotificationName:@"PushNotificationReceived" object:nil];
在 Controller 类中,您可以观察通知并做任何您想做的事。
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadWebview:) name:@"PushNotificationReceived" object:nil];
这是其中一种方式。
关于ios - 收到推送通知时如何重定向到 Webview 中的特定页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32111975/