php-gcm icon indicating copy to clipboard operation
php-gcm copied to clipboard

Complex data in push message

Open svok opened this issue 8 years ago • 1 comments

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 avatar May 27 '16 07:05 svok

@svok which version are you encountering these errors? I believe they are only issues in 1.x versions.

lkorth avatar Jun 24 '16 17:06 lkorth