Firebase silent notification does not start up a closed iOS app

倖福魔咒の 提交于 2019-12-04 01:11:50

问题


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
}

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

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


回答1:


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!

From 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


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

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.



来源:https://stackoverflow.com/questions/50241353/firebase-silent-notification-does-not-start-up-a-closed-ios-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!