ios - 收到推送通知时如何重定向到 Webview 中的特定页面

标签 ios xcode redirect uiwebview push-notification

我的 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/

相关文章:

ios - 根据单元格选择将核心数据传递给 ViewController

ios - 更改事件共享中按钮的色调

c++ - 哪个对象更适合使用 b2EdgeShape 与 b2ChainShape 创建曲线?

Swift UITableView 不会调整到更大的尺寸

security - 为什么 Gmail 中的链接会重定向?

php - 如何在 Slim 2 和 PHPUnit 中测试重定向?

ios - 防止 View 被拖出屏幕

ios - 游戏中心。获取真实姓名

objective-c - 保持 NSTableCellView 处于焦点

java - RequestDispatcher.forward() 和 HttpServletResponse.sendRedirect() 有什么区别?