NOT MAINTAINED! ⛔️ Push notifications/messages for mobile devices. Supports iOS, Android (C2DM, GCM), Blackberry and Windows Mobile (toast only). A Symfony2 bundle.
/**
* @Route("/test", name="test")
*/
public function testAction(Request $request)
{
$notice = json_decode(Curl::curlGet('https://api.chucknorris.io/jokes/random'));
// Curl::curlGet($url) is a personal library and they work
$out = [];
foreach ($this->findAll("AppBundle:Device") as $device) {
/* @var $device Device */
switch (strtolower($device->getOs())) {
case 'ios':
$message = new iOSMessage();
$message->setMessage($notice->value);
$message->setAPSSound('default');
$message->setDeviceIdentifier($device->getToken());
$out[] = $this->container->get('rms_push_notifications')->send($message);
break;
case 'android':
$message = new AndroidMessage();
$message->setFCM(true);
$message->setMessage($notice->value);
$message->setDeviceIdentifier($device->getToken());
$out[] = $this->container->get('rms_push_notifications')->send($message);
break;
}
}
return new Response($notice->value . ' - [' . implode(' | ', $out) . ']');
}
If I try to send a notification, the server response is
Every time Chuck Norris watches on Olympic event, he wins a gold medal. - [Android: | iOS: 1]
Debugging the code in AndroidFCMNotification.php I see:
foreach ($this->responses as $response) {
$message = json_decode($response->getContent());
-> // $message is null !!!
if ($message === null || $message->success == 0 || $message->failure > 0) {
if ($message == null) {
$this->logger->error($response->getContent());
} else {
foreach ($message->results as $result) {
if (isset($result->error)) {
$this->logger->error($result->error);
}
}
}
return false;
}
}
This is my google-services_json.js and I think it use the correct api_key
I've some trouble with FCM notifications.
This is my config.yml
And this is my test code
If I try to send a notification, the server response is
Every time Chuck Norris watches on Olympic event, he wins a gold medal. - [Android: | iOS: 1]
Debugging the code in AndroidFCMNotification.php I see:This is my google-services_json.js and I think it use the correct api_key
I try the code on my MacBookPro and on my web server (based on Debian 7), but the responses are the same.
How can fix my code?