gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 03:30:57 26 4
gpt4 key购买 nike

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/

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