【问题标题】:How to set multiple audience in urban airship城市飞艇如何设置多个观众
【发布时间】:2015-10-19 09:57:42
【问题描述】:

我正在使用 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":false,"error":"无法解析请求 body.","error_code":40210,"details":{"error":"指定多个 选择器的类型('android_channel' 是 意外)","路径":"audience.android_channel[0]","location":{"line":1,"column":127}},"operation_id":"2b00a2a0-73cd-11e5-a4ba-90e2ba2901f0 "} 收到来自服务器的否定响应:40

【问题讨论】:

    标签: php android ios push-notification urbanairship.com


    【解决方案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 都能正常运行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多