Ios Firebase推送静默推送通知HTTP v1

Ios Firebase推送静默推送通知HTTP v1,ios,firebase,firebase-cloud-messaging,Ios,Firebase,Firebase Cloud Messaging,通过其或通过其向FCM发送以下请求不会产生预期的无声通知 POST https://fcm.googleapis.com/v1/projects/project-name/messages:send { "message": { "apns": { "payload": { "aps": { "content-available": 1 }, "some": "test", "and":

通过其或通过其向FCM发送以下请求不会产生预期的无声通知

POST https://fcm.googleapis.com/v1/projects/project-name/messages:send
{
  "message": {
    "apns": {
      "payload": {
        "aps": {
          "content-available": 1
        },
        "some": "test",
        "and": "more",
        "nested": {
          "content": "with_value"
        }
      },
      "headers": {
        "priority": "5"
      }
    },
    "data": {
      "some": "content"
    },
    "token": "..."
  }
}
它也不能通过遗留API工作

POST https://fcm.googleapis.com/fcm/send
{
    "to": "...",
    "content_available": true,
    "priority": "normal",
    "data": {
        "some-key": "value"
    }
}
但是,如果我不使用FCM层直接将请求发送到APN,以下代码将正确执行:

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any],
                 fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
    print(userInfo)
    let content = UNMutableNotificationContent()
    content.title = "Some title"
    content.body = "Some content"

    let uuidString = UUID().uuidString
    let request = UNNotificationRequest(identifier: uuidString,
                content: content, trigger: nil)

    let notificationCenter = UNUserNotificationCenter.current()
    notificationCenter.add(request) { (error) in
       if error != nil {
          // Handle any errors.
       }
    }

    completionHandler(.newData)
}
其他信息:

  • badge
    添加到
    apns
    会更新应用程序上的徽章,以便收到通知
  • 设置
    通知
    键可在通知中心创建通知
  • 我所有的例子都得到了FCM的成功回复
  • 两个电话我都试过很多组合

问题解决了吗?对于传统Api,您应该添加“通知”标签。例如:{“to”:“…”,“notification”:{“body”:“body of Your notification”,“title”:“title of Your notification”},“content_available”:true,“data”:{“some key”:“value”}不,我没有。我想让它与新的API一起工作,但从未实现。我最终直接使用了APN