Firebase静默通知无法启动已关闭的iOS应用 [英] Firebase silent notification does not start up a closed iOS app

本文介绍了Firebase静默通知无法启动已关闭的iOS应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Can FCM silent notification start up a closed iOS app?

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应用.

However, this payload does not start up my iOS app if the user closes it.

如何在收到无提示通知时使iOS启动我的应用?

How to make the iOS to start my app whenever a silent notification is received?

推荐答案

这是不启动应用程序的预期行为.我的意思是为什么呢?用户出于某种原因决定终止该应用程序.他们不想再用电池或带宽了!

It's the expected behavior to not launch the app. I mean why should it? The user for some reason has decided to kill the app. They don't want battery or bandwidth getting used for it anymore!

来自文档.

使用此方法为您的应用处理传入的远程通知. 与application(_:didReceiveRemoteNotification :)方法不同,后者 仅当您的应用在前台运行时才被调用 当您的应用在前台运行时调用此方法,或者 背景.此外,如果您启用了远程通知 后台模式,系统将启动您的应用程序(或将其从挂起状态唤醒),并在收到远程通知时将其置于后台状态.但是,如果用户强行退出了应用程序,系统将不会自动启动它.在这种情况下,用户必须重新启动您的应用程序或重新启动设备,然后系统才会尝试再次自动启动您的应用程序

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


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


For non-silent notifications. They would get delivered to the device. But not to the app.

如果您在iPhone上强制退出Whatsapp,而您的母亲给您发送了一条消息,那么您的 iPhone 会在通知中显示该消息.但是,它不会触发您的任何AppDelegate方法.仅在未终止应用程序的情况下才触发AppDelegate方法.

If you force-quite your Whatsapp on your iPhone and your mother sends you a message, then your iPhone would show it among its notifications. However it won't trigger any of your AppDelegate methods. AppDelegate methods are only triggered if the app is not user terminated.

这篇关于Firebase静默通知无法启动已关闭的iOS应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆