0

I have figured out how to send a push notification with WonderPush through two ways:

#1

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://management-api.wonderpush.com/v1/deliveries');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);

$fields = array(
  'accessToken' => "xxx",
  'targetIds' => "123",
  'campaignId' => "123abc",
  'notification' => array(
    'alert' => array(
      'title' => "Some title",
      'text' => "Some text"
    )
  )
);

curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));

$headers = array();
$headers[] = 'Content-Type: application/x-www-form-urlencoded';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close($ch);

#2:

require_once('inc/WonderPush/init.php');
$wonderpush = new \WonderPush\WonderPush('xxx', 'yyy');
$response = $wonderpush->deliveries()->create(
    \WonderPush\Params\DeliveriesCreateParams::_new()
        ->setTargetSegmentIds('@ALL')
        ->setTargetUserIds('123')
        ->setCampaignId('123abc')
        ->setNotification(\WonderPush\Obj\Notification::_new()
            ->setAlert(\WonderPush\Obj\NotificationAlert::_new()
                ->setTitle('Some title')
                ->setText('Some text')
            ))
);

The first method uses the pre-created "campaign" which includes a custom URL when the user clicks the notification and also buttons with possible other URLs. However, I can't change anything on-the-fly, i.e. no custom title, text or URL.

The second method is created by code and there I can have custom titles and texts, but the URL is taken from the settings in WonderPush and I can't make any buttons at all.

Can someone help me to do what I want to do with either of my examples (or a totally new way)?

Thomas
  • 313
  • 1
  • 11

1 Answers1

0

There are basically two ways to do that:

  1. You can use the notificationOverride parameter to apply a partial diff on the notification that is filled within the campaign in the dashboard.
  2. You can use {{someParameter}} within the notification configured in the dashboard, and fill those parameters when triggering the delivery using notificationParams={"someParameter": "someValue"}.

Best,

ofavre
  • 4,488
  • 2
  • 26
  • 23