如何控制推送通知中按钮的功能?
我能够向 iOS 设备发送推送通知。通知上有一个“关闭”按钮和一个“查看”按钮。当用户点击“查看”按钮时,应用程序将打开根视图控制器。该应用程序内有一个新闻部分。假设该通知是为了提醒用户有新的新闻报道可供他们查看。如果他们点击“查看”,将显示根视图控制器,而不是新闻视图控制器。我将如何打开新闻视图控制器? Facebook 经常使用这个。这是否需要在服务器或应用程序内进行更改?感谢您的帮助!
I'm able to send push notifications to iOS devices. There is a "Close" button on the notification and a "View" button. When the user hits the "View" button the app opens up to the root view controller. Within the app there is a news section. Let's say the notification is to alert the user that there is a new news story for them to see. If they hit "View", the root view controller will show, instead of the news view controller. How would I go about opening the news view controller? Facebook uses this a lot. Would this be something to change on the server or within the app? Thanks for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于通知中的 iOS 8+ 操作按钮:
对于本地通知,当按下通知上的按钮(锁定屏幕或横幅)时,
appDelegate
会调用此方法:对于 推送通知,当按下通知上的按钮(锁定屏幕或横幅)时,
appDelegate
会调用此方法:For iOS 8+ action button in notifications:
For local notification,
appDelegate
calls this method when a button on the notification (lock screen or banner) is pressed:For push notification,
appDelegate
calls this method when a button on the notification (lock screen or banner) is pressed:您必须检查应用程序委托中的启动选项:
您可以在其中获取推送通知的有效负载字典。
You have to check the launch options in your application delegate:
There you can obtain the payload dictionary of the push notification.