2015-10-19 84 views
0

我正在使用php客户端向城市飞艇发送通知请求。 对于我已经提到下面的链接。
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”:假的, “错误”: “无法解析请求 身体。”, “ERROR_CODE”:40210, “细节”:{ “错误”:”指定多个 类型的选择器('android_channel'为 意外)“,”path“:”audience.android_channel [0]“,”location“:{”line“:1,”column“:127}}, “operation_id”: “2b00a2a0-73cd-11e5-a4ba-90e2ba2901f0”} GOT从服务器否定响应:40

回答

1

得到了城市飞艇支持的答复。下面是答案。

"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。