gpt4 book ai didi

php - Urban Airship 如何设置多个观众

转载 作者:行者123 更新时间:2023-11-29 01:33:27 25 4
gpt4 key购买 nike

我正在使用 php 客户端向 Urban Airship 发送通知请求。为此,我在下面提到了链接。
https://support.urbanairship.com/entries/70144047-Simple-PHP-API-v3-examples
在该受众群体中设置为

$push = array("audience"=>"all", "notification"=>$notification, "device_types"=>$platform);

我想向选定的 iOS 和 Android 设备发送通知。为此,我分别为 iOS 和 android 创建了一个数组。像这样。

$iosDevices = array(); 
array_push($iosDevices, "Channel_id_for_iOS_device_1");
array_push($iosDevices, "Channel_id_for_iOS_device_2");
$main__channel['ios_channel'] = $iosDevices;
$push = array("audience"=> $main__channel,"notification"=>$notification, "device_types"=>$platform);

这工作正常,但是当我尝试添加 android 的 channel ID 数组时,它不允许我这样做。

$androidDevices = array(); 
array_push($androidDevices, "Channel_id_for_android_device_1");
array_push($androidDevices, "Channel_id_for_android_device_2");
$main_channel['android_channel'] = $androidDevices;
$push = array("audience"=> $main__channel,"notification"=>$notification, "device_types"=>$platform);

我想向 iOS 和 Android 设备 ID(仅选择一个)发送通知。
我想将这些数组传递给观众。有什么办法吗?

响应

{"ok":false,"error":"Could not parse request body.","error_code":40210,"details":{"error":"Specified more than one type of selector ('android_channel' was unexpected)","path":"audience.android_channel[0]","location":{"line":1,"column":127}},"operation_id":"2b00a2a0-73cd-11e5-a4ba-90e2ba2901f0"} Got negative response from server: 40

最佳答案

得到 Urban Airship 支持的回复。下面是答案。

"audience": {
"OR": [
{ "ios_channel": [
"Channel_id_for_iOS_device_1",
"Channel_id_for_iOS_device_1"
] },
{ "android_channel": [
"Channel_id_for_android_device_1",
"Channel_id_for_android_device_2",
"Channel_id_for_android_device_3"
] }
]
}

我测试过,它在 iOS 和 Android 上都运行良好。

关于php - Urban Airship 如何设置多个观众,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33211551/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com