城市飞艇如何设置多个观众
How to set multiple audience in urban airship
我正在使用php客户端向城市飞艇发送通知请求。
为此,我在下面提到了 link。
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 的频道 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
得到城市飞艇支持的回复。下面是答案。
"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客户端向城市飞艇发送通知请求。
为此,我在下面提到了 link。
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 的频道 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
得到城市飞艇支持的回复。下面是答案。
"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 都可以正常工作。