options参数不支持third_party_channel第三方厂商通道参数
Ethennoob opened this issue · 0 comments
Ethennoob commented
https://github.com/jpush/jpush-api-php-client/blob/master/src/JPush/PushPayload.php
options里面没有加上third_party_channel参数的判断,导致vivo厂商通道的参数无法加入
"options": {
"third_party_channel": {
"vivo": {
"distribution": "ospush",
"classification": 1//可选,int 类型,2020/06 新增,和vivo官方字段含义一致 0 代表运营消息,1 代表系统消息,不填vivo官方默认为0
}
}
}
https://go48pg.yuque.com/docs/share/83fb8f80-1edb-48ca-8e4a-df8a45d82c6b?#
应修改为
public function options(array $opts = array()) {
# $required_keys = array('sendno', 'time_to_live', 'override_msg_id', 'apns_production', 'apns_collapse_id', 'big_push_duration');
$options = array();
...//省略
if (isset($opts['big_push_duration']) && $opts['big_push_duration'] <= 1400 && $opts['big_push_duration'] >= 0) {
$options['big_push_duration'] = $opts['big_push_duration'];
}
//第三方厂商通道参数
if (isset($opts['third_party_channel'])) {
$options['third_party_channel'] = $opts['third_party_channel'];
}
$this->options = $options;
return $this;
}
调用为
$options = array(
'apns_production' => env('JPUSH_APNS_PRODUCTION', false),
'third_party_channel' => [
'vivo' => [
'distribution' => 'ospush',
'classification' => 1//可选,int 类型,2020/06 新增,和vivo官方字段含义一致 0 代表运营消息,1 代表系统消息,不填vivo官方默认为0
]
]//https://go48pg.yuque.com/docs/share/83fb8f80-1edb-48ca-8e4a-df8a45d82c6b?#
);
try{
$response = $push->setCid($cid)
->setPlatform (['android', 'ios'])
->addRegistrationId($audience)
->iosNotification($iosAlert, $ios_notification)
->androidNotification($androidAlert, $android_notification)
->options($options)
->send();
}catch(\JPush\Exceptions\JPushException $e){
$result = array(
'code' => $e->getCode(),
'message' => $e->getMessage(),
);
return $result;
}