gpt4 book ai didi

ios - 在通知横幅中显示之前处理推送通知

转载 作者:可可西里 更新时间:2023-11-01 00:52:09 25 4
gpt4 key购买 nike

我想在收到远程通知时在应用程序中执行一些代码,然后再显示 IOS 通知的横幅/警报。我的想法是捕获通知中的 json,并根据它的内容和其他规则我知道是否应该为用户显示通知。

最佳答案

您可以创建“静默”推送通知。 (请参阅 Apple 文档)当您收到此类无提示通知时:

  • 解析 JSON
  • 决定是否展示它
  • 如果是,就显示一个普通的本地通知,它看起来和用户的推送通知一样

您会发现大量关于如何创建本地通知的 SO 教程。

你必须实现 application:didReceiveRemoteNotification: fetchCompletionHandler。

Use this method to process incoming remote notifications for your app. Unlike the application:didReceiveRemoteNotification: method, which is called only when your app is running in the foreground, the system calls this method when your app is running in the foreground or background. In addition, if you enabled the remote notifications background mode, the system launches your app (or wakes it from the suspended state) and puts it in the background state when a remote notification arrives. However, the system does not automatically launch your app if the user has force-quit it. In that situation, the user must relaunch your app or restart the device before the system attempts to launch your app automatically again.

关于ios - 在通知横幅中显示之前处理推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34274972/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com