php-gcm
php-gcm copied to clipboard
Complex data in push message
The following code:
<?php
$message = new \PHP_GCM\Message();
$message->addData('test', ['xxx' => 'yyy']);
$client = new \PHP_GCM\Sender($this->apiKey);
$client->send($message, $token, $this->retryTimes);
generates an error: Expecting string but array id found.
The other function:
<?php
$message = new \PHP_GCM\Message();
$message->addData('test', ['xxx' => 'yyy']);
$client = new \PHP_GCM\Sender($this->apiKey);
$client->sendMulti($message, $token, $this->retryTimes);
works with no exceptions, but the JSON object comes as a string:
{
"test": "{\"xxx\":\"yyy\"}"
}
@svok which version are you encountering these errors? I believe they are only issues in 1.x versions.