我正在使用 whatsapp cloud api 向客户端发送消息,它在 android 上工作正常但不能在 IOS 上工作,是否有任何额外的 IOS 设置步骤?
只有文字的普通消息可以正常发送,但是带有图片或文档的消息无法发送
对于发送到 Android 和 iOS 的消息,API 返回代码 200,但只有 Android 用户才能收到传递的消息。
示例代码:
url = 'https://graph.facebook.com/v15.0/{}/messages'.format(FROM_PHONE_NUMBER_ID)
headers = {
'Authorization': 'Bearer {}'.format(ACCESS_TOKEN),
'Content-Type': 'application/json'
}
data = {
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": "{}".format(numero),
"type": "template",
"template":{
"name":"bancario_atm",
"language":{
"code":"en_US"
},
"components":[
{
"type":"header",
"parameters":[{
"type":"document",
"document":{
"id":"{}".format(media_id),
"filename":"Reporte_{}_{}_{}.xlsx".format(entidad,fecha_proceso, fecha_hora)
},
}]
},
{
"type":"body",
"parameters":[
{
"type":"text",
"text":"%s" % fecha_proceso
},
{
"type":"text",
"text":"%s" % fecha_hora
}
]
}
]
}
}
response = requests.post(url, headers=headers, json=data)
故障排除指南说Whatsapp应用程序版本必须优于2.21.170.4,我检查了我正在使用的测试手机应用程序版本,没问题,所以这不是问题。
有时会出现媒体消息,但只出现在 Whatsapp 网页上,而不是手机上,这让我觉得 Whatsapp 的某些配置没有传达清楚。