OneSignal 通知重定向到无效 URL

OneSignal notification redirect to invalid URL

我有一个 OneSignal 设置,用于通过外部用户 ID 向特定用户发送通知,如下所示


$fields = [
    'app_id'                        => env( 'app.onesignalAppKey' ),
    'priority'                      => 10, // High priority.
    'include_external_user_ids'     => [ md5( $contact['email'] ) ],
    'channel_for_external_user_ids' => 'push',
    'headings'                      => [ 'en' => $this->subject ],
    'contents'                      => [ 'en' => $this->message ],
    'url'                           => [ 'en' => base_url( $this->args['log_extra']['url'] ) ]
];

$fields = json_encode($fields);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, env( 'app.Onesignalurl'));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=utf-8',
    'Authorization: Basic '. env( 'app.onesignalAPI' )));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$response = curl_exec($ch);
curl_close($ch);

在测试时我收到通知,但时钟通知重定向到错误 url。

https://example.com/onesignal/{"en"=>"https://example.com/correct-path"}

OneSignal service worker 安装范围设置为 /onesignal/

我没看错吧..?

只需将 URL 作为字符串放入 $fields 数组中,而不是数组。 喜欢:

'url' => base_url( $this->args['log_extra']['url'] ),