Python 解析Firebase增强推送通知

Python 解析Firebase增强推送通知,python,ios,firebase,parse-platform,firebase-cloud-messaging,Python,Ios,Firebase,Parse Platform,Firebase Cloud Messaging,我正在将解析迁移到Firebase,但在增强推送通知方面遇到了问题 解析数据(iOS端)如下所示: {"ast": {"alert": { {"body": "body_test", "title": "title_test", "description": "description", "endpoint-proposal": "https://.." "launch-image": "https://..." }, "sound":

我正在将解析迁移到Firebase,但在增强推送通知方面遇到了问题

解析数据(iOS端)如下所示:

{"ast":
  {"alert": {
    {"body": "body_test",
     "title": "title_test",
     "description": "description",
     "endpoint-proposal": "https://.."
     "launch-image": "https://..."
  },
  "sound": "chime",
  ... 
}
使用Firebase API时,ast标记是['notification']['body']

如果我发送

['notification']['body'] = 'Hello' 
它工作正常,并产生以下推力:

{"ast":
  {"alert": "Hello"}
}...
因此,这里的问题是,我需要在该标记(警报)中发送一个字典,但我不能这样做,因为firebase将该值设置为string

python中的示例:

alert = dict()
alert['title'] = 'title'
alert['description'] = 'description'
alert['endpoint-proposal'] = 'https://..'
alert['launch-image'] = 'https://..'

fcm_payload['notification']['body'] = alert 

send_push()
在iOS方面,我得到:

[AnyHashable("gcm.message_id"): 0:123456789,
 AnyHashable("aps"): {
    alert = "{\"body\": \"body\",
              \"launch-image\": \"https://...\",
              \"endpoint-proposal\": \"https://...\",
              \"description\": \"description\",
              \"title\": \"title\"}";
}]
始终作为字符串:S


有什么方法可以将该警报作为dict发送吗?

FCM将始终将
通知
参数视为
字符串。这只是行为。您需要做的是利用有效负载并将其放入自定义键值对中:

在iOS上,如果消息通过APNS发送,则表示自定义数据字段。如果它是通过FCM连接服务器发送的,它将在AppDelegate应用程序中表示为键值字典:didReceiveMemotentification:


更多详情见本文件。我认为对于您的情况,您只需在有效负载中同时使用
通知
数据
参数。

已经对其进行了测试。不管怎样,它总是将值设置为字符串。