Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

options参数不支持third_party_channel第三方厂商通道参数 #94

Open
Ethennoob opened this issue Nov 3, 2021 · 0 comments
Open

Comments

@Ethennoob
Copy link

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?#
image

应修改为

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;
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant