ios - Firebase 静默通知不会启动已关闭的 iOS 应用

标签 ios firebase push-notification apple-push-notifications firebase-cloud-messaging

FCM 静默通知能否启动已关闭的 iOS 应用?

Request Type: POST

Request URL: https://fcm.googleapis.com/fcm/send

Request Headers:

Authorization -> key=MY_KEY

Content-Type -> application/json

Request Body:

{
  "to": "/topics/my_topic",
  "content_available": true,
  "data": {
    "contentAvailable": 1
  },
  "priority": 10
}

但是,如果用户关闭此有效负载,我的 iOS 应用程序不会启动。

如何让 iOS 在收到静默通知时启动我的应用程序?

最佳答案

不启动应用程序是预期的行为。我的意思是为什么要这样做?出于某种原因,用户决定终止该应用程序。他们不想再为此耗费电池或带宽!

来自 documentation .

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


用于非静音通知。他们会被传送到设备。但不是应用程序。

如果您在 iPhone 上强制关闭 Whatsapp,而您的母亲向您发送了一条消息,那么您的 iPhone 会在通知中显示该消息。但是它不会触发您的任何 AppDelegate 方法。 AppDelegate 方法仅在应用未被用户终止时才会触发。

关于ios - Firebase 静默通知不会启动已关闭的 iOS 应用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50241353/

相关文章:

ios - 如何使用UIStackView按比例缩放大小?

ios - 是否可以设置 AVPlayer 以允许设备在视频播放期间进入休眠状态?

ios - UICollectionViewCell 的后台线程快照 = WebCore 崩溃

firebase - 将Firebase连接到我的TextField/ Material 登录页面代码

android firebase 通知不导航到确切的页面

ios - 除了组合器中的前一个和当前纹理单元之外,我还可以引用其他纹理单元吗?

javascript - 带有 FCM 推送通知的 Angular Service worker

reactjs - 在 React.JS 中刷新后,如何让用户保持登录到 firebase 的状态?

ios - iOS 静默通知有多可靠?

android gcm推送通知仅播放声音,不显示在顶部