当应用程序处于后台时,推送通知 FCM 不会出现

Push Notification FCM doesnt appear when app is in background

我想为聊天应用程序实施 FCM 推送通知服务,我按照 Firebase 文档中的步骤操作,当它们从 Firebase 控制台发送到我的设备时,我会收到通知。 当我尝试使用我的服务器端通过 FCM 使用 http post 将通知发送到设备时 https://fcm.googleapis.com/fcm/send :

我的 headers 是:

Content-Type:application/json
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA

我的 body 是:

{ "notification": {
    "title": "Portugal vs. Denmark",
    "text": "5 to 1"
  },
  "to" : "myDeviceRegistrationId"
}

当我的应用程序处于后台时,什么也没有发生(我重复一遍,但在控制台上,我在后台收到通知)

当应用程序处于活动状态并且我将此通知发送到我的设备时,我在我的控制台日志中收到以下消息,所以我想我收到了通知但由于某种原因它没有在后台显示它

Message ID: 0:1470132526023119%8d989dbf8d989dbf
        %@ [aps: {
            alert =     {
                body = "5 to 1";
                title = "Portugal vs. Denmark";
            };
        }, gcm.message_id: 0:1470132526023119%8d989dbf8d989dbf]
        2016-08-02 13:08:46.913 ProjectAlpha[13324:4726432] Warning: Application delegate received call to -application:didReceiveRemoteNotification:fetchCompletionHandler: but the completion handler was never called.

我错过了什么? 谢谢你的帮助..

你开启后台模式了吗?

Look this

我通过删除

解决了我的问题

FirebaseAppDelegateProxyEnabled

来自 Info.plist 的密钥并使用

"content_available": true

在应用程序处于后台时接收消息。

现在它完美运行了:)