应用程序打开时可以收到静默推送通知吗?

can a silent push notification be received when the application is open?

我想了解如果用户打开应用程序,静默推送通知...{aps: {content-available: 1}} ...是否可以被我的 iOS 应用程序接收并且正在使用它。

我已经阅读了一些关于它的文档,但我无法找到明确的答案。

有人吗?

当您的应用程序处于 active/open/in 前台时,您将在 AppDelegate class 的 didReceiveRemoteNotification 中收到推送通知。这是默认静音。用户不会得到任何信息。完全靠开发者,怎么处理。

Official documentation on 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.

  • application:didReceiveRemoteNotification::仅当应用程序处于前台时调用
  • application:didReceiveRemoteNotification:fetchCompletionHandler::如果应用程序在前台或后台时调用

这适用于所有远程通知,也适用于静默通知。